HTTP Error 431 - Request Header Field(s) Too Large
tianenpang
PROOP

a year ago

Hello guys, we are encountering an HTTP Error 431 - Request Header Field(s) Too Large when deploying our Next.js application using the Nixpacks builder on Railway. We have thoroughly investigated and ruled out other potential causes for this error on our end.

Could you please confirm if there is any request header size limit enforced by Railway? If so, is there a way to increase the allowed size for request headers?

Any guidance or suggestions on resolving this issue would be greatly appreciated, thank you for your help!

59 Replies

tianenpang
PROOP

a year ago

4b7ea996-5769-4729-abf5-aba577a03dd8


brody
EMPLOYEE

a year ago

please send a link that show this error


tianenpang
PROOP

a year ago

Hi, since our app restricts access after authentication, we can’t provide a public URL at the moment, but below are the detailed steps to reproduce 🙏🏻

Steps to reproduce:

  1. Go to https://zigma.io

  2. Click Sign In in the top right

  3. You’ll be redirected to https://app.zigma.io

  4. Sign in or sign up and social login is available

  5. Open the Network tab in the browser's developer tools

  6. Refresh the page and you'll see requests with a 431 status code in the Network panel


tianenpang
PROOP

a year ago

Please let me know if you need any further information


brody
EMPLOYEE

a year ago

We have thoroughly investigated and ruled out other potential causes for this error on our end.
can you shine some light on how you've come to this conclusion?


brody
EMPLOYEE

a year ago

just on [https://app.zigma.io/dashboard/](https://app.zigma.io/dashboard/) i do not see any fetch reqs that are failing


tianenpang
PROOP

a year ago

can you shine some light on how you've come to this conclusion?

  1. Disabled Cloudflare proxy, using only DNS (issue persists)

  2. Simulated the deployment environment locally with Docker (no issues found)

  3. No relevant logs in Next.js (no issues found)

At this point, I can't confirm if there are any additional limitations in Railway or Nixpacks 🤔


brody
EMPLOYEE

a year ago

to be perfectly honest with you, thats unfortunately not a very compressive test


tianenpang
PROOP

a year ago

just on https://[app.zigma.io](app.zigma.io)/dashboard/ i do not see any fetch reqs that are failing

Did you visit https://zigma.io first? Some cookies are set there and shared with the subdomain (app.zigma.io), which leads to the Request Header Field(s) Too Large issue

1283844415512645600
1283844415869423900


brody
EMPLOYEE

a year ago

gotcha


brody
EMPLOYEE

a year ago

nope no errors still


tianenpang
PROOP

a year ago

to be perfectly honest with you, thats unfortunately not a very compressive test

You're right, since this issue is quite tricky and first time encountering it 😢 any suggestions would be greatly appreciated


brody
EMPLOYEE

a year ago

have you tried running your site locally and sending artificially large headers to your app via curl or postman?


passos
MODERATOR

a year ago

no errors here too, even when going to main dashboard or main page

1283850624651362300


passos
MODERATOR

a year ago

you could try in a incognito window?


passos
MODERATOR

a year ago

or maybe something about your specific session is too big that may cause some issue with headers, fresh social login account would be a nice test


tianenpang
PROOP

a year ago

have you tried running your site locally and sending artificially large headers to your app via curl or postman?

I tried setting 10+ cookies with different names for the auth token and included them in the request, but couldn’t reproduce the issue locally. (the request header size during testing was around 18 KB, which is much larger than in production)


tianenpang
PROOP

a year ago

or maybe something about your specific session is too big that may cause some issue with headers, fresh social login account would be a nice test

Thank you for your response, unfortunately, similar issues are also occurring with some new users with diff browsers


tianenpang
PROOP

a year ago

What’s confusing now is where this response is coming from 🤔

1283853767464452000


brody
EMPLOYEE

a year ago

can you attempt the same test with this -


tianenpang
PROOP

a year ago

with the same request headers?


brody
EMPLOYEE

a year ago

yep


brody
EMPLOYEE

a year ago

send headers as big or bigger than what you send to your production app when you are getting that 431


tianenpang
PROOP

a year ago

after testing step by step, the response is consistently successful


tianenpang
PROOP

a year ago

for the 431 request, I noticed that the x-railway-request-id is missing from the response headers, can this be understood as the request not yet reaching Railway? 🤔


brody
EMPLOYEE

a year ago

your domain is behind cloudflare right?


tianenpang
PROOP

a year ago

Yeah, but DNS only


brody
EMPLOYEE

a year ago

i have additional logging in place, can you try it again?


tianenpang
PROOP

a year ago

Just tried

1283870993449750500


brody
EMPLOYEE

a year ago

send the headers here please


tianenpang
PROOP

a year ago

these are the headers from the minimal issue isolation

Accept: "text/x-component",
Next-Action: "8702f98122602daac9043a744a5517df7c4e6826",
Next-Router-State-Tree: "%5B%22%22%2C%7B%22children%22%3A%5B%22dashboard%22%2C%7B%22children%22%3A%5B%5B%22workspaceId%22%2C%227cfcc9dd-30d2-4a32-8917-1d6f1e16978b%22%2C%22d%22%5D%2C%7B%22children%22%3A%5B%22projects%22%2C%7B%22children%22%3A%5B%22__PAGE__%22%2C%7B%7D%2C%22%2Fdashboard%2F7cfcc9dd-30d2-4a32-8917-1d6f1e16978b%2Fprojects%22%2C%22refresh%22%5D%7D%5D%7D%5D%7D%5D%7D%2Cnull%2Cnull%2Ctrue%5D"

tianenpang
PROOP

a year ago


brody
EMPLOYEE

a year ago

what about the cookie? there is no way thats all the headers


tianenpang
PROOP

a year ago

this request info comes from the request's initiator, in other words, the request here resulted in a 431 error 🤔

1283875650419167500


brody
EMPLOYEE

a year ago

right but that request would also include cookies?


tianenpang
PROOP

a year ago

yes, my bad. the default credentials is same-origin, so cookies will be included


brody
EMPLOYEE

a year ago

please send the same sized headers to that link


tianenpang
PROOP

a year ago

sent


brody
EMPLOYEE

a year ago

200?


tianenpang
PROOP

a year ago

yeah, getting 200 with total 8.22KB content

1283878711938121700


brody
EMPLOYEE

a year ago

7682 bytes of just headers, and cookie itself is only 6395 bytes


brody
EMPLOYEE

a year ago

I don't think you are replaying the request to my endpoint correctly, those are miniscule sizes


tianenpang
PROOP

a year ago

I can confirm that I included all the headers from the 431 request, I've double-checked each request header

1283880086638035000


tianenpang
PROOP

a year ago

Could you please check the complete HTTP logs for Project ID: 4b7ea996-5769-4729-abf5-aba577a03dd8? I don't see any records of the 431 error in my HTTP log panel.


brody
EMPLOYEE

a year ago

im not able to do that right now, sorry


tianenpang
PROOP

a year ago

Is there a way to specify the Node version for the Nixpacks builder? 👀


brody
EMPLOYEE

a year ago

yep! -


tianenpang
PROOP

a year ago

How can I request to view the complete HTTP logs? 👀


brody
EMPLOYEE

a year ago

im sorry but that request is not something we can fulfil right now


tianenpang
PROOP

a year ago

It looks like the node version isn't following the NIXPACKS_NODE_VERSION 🤔

1283888507533660200
1283888507810480000


brody
EMPLOYEE

a year ago

why do you say that? it says node 20 in that table


tianenpang
PROOP

a year ago

will it use the same minor version as NIXPACKS_NODE_VERSION? 🤔


brody
EMPLOYEE

a year ago

Only a major version can be specified. For example, 18.x or 20.


tianenpang
PROOP

a year ago

Is there any way to determine if these 431 requests have reached Railway?


brody
EMPLOYEE

a year ago

does your app itself not log requests?


tianenpang
PROOP

a year ago

The error fetch is from Next.js and fetch itself for rendering, but it's unclear which program / process returned the 431 (Railway or something else, the Cloudflare is DNS only already)


brody
EMPLOYEE

a year ago

railway would return a plaintext response when you exceed the header limit size, you have since shown me an html page


youssefsiam38
HOBBY

a year ago

I have the same issue, and I can tell it is railway as I am not using cloudflare proxy and the response includes the header (Server: railway-edge)

I am ready to provide any additional information for this if it is needed


brody
EMPLOYEE

a year ago

Please open your own thread, OP was not running into any Railway limitations, but you might be.


Loading...