Skip to content
431 HTTP error
genai_works
OP

2 years ago

I see that users receive 431 HTTTP error when visiting my next.js website

Is it possible to configure variable that define the length of headers? (e.g. client_header_buffer_size or something like that).

Solved

5 Replies

2 years ago

Hi, do you have an example to a request/way to reproduce this ?


Status changed to Awaiting User Response Railway • about 2 years ago


genai_works
OP

2 years ago

https://station-server.railway.app/attachments/att_01j6ezttf3fye8c0er92qzp1tsI just see that users can experience this problem. For me it's not a case and I don't see a way to reproduce it. By it seems to happen if cookies size is larger than server can accept (I don't know specific limitation set on the server, probably 2-4 Kb)

From development side, I am trying to reduce the size of cookies that we set after authorization. But probably other services are also creating large cookies (e.g. we use Posthog for analytics). And that's why when cookies size reach some critical point, users receive 431 http error.


Status changed to Awaiting Railway Response Railway • about 2 years ago


2 years ago

linking this stackoverflow thread if it helps: https://stackoverflow.com/questions/686217/maximum-on-http-header-values

Usually this limit is handled by the webserver, but I've also asked our infra team to check if this could be coming from our proxy (my assumption is, it shouldn't, and would be something from your website. but it also doesn't look like a classic nextjs error)

I'll keep you updated


Status changed to Awaiting User Response Railway • about 2 years ago


genai_works
OP

2 years ago

After investigation, it seems to me that issue is related to posthog

https://medium.com/@hadikusumahendrawan/fixing-431-header-too-large-error-posthog-integration-best-practices-7ea0fd7ee6a3

https://posthog.com/tutorials/cookieless-tracking

I am trying to fix it, by changing persistence init parameter


Status changed to Awaiting Railway Response Railway • about 2 years ago


genai_works
OP

2 years ago

Posthog seems to be setting multiple cookies instead of a single one. As a number of cookies grows, at some point error is reachedhttps://station-server.railway.app/attachments/att_01j6f90c44fs3rq0hrjrw9g497


Status changed to Solved ntheck • about 2 years ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...