HTTP Error 431 - Request Header Field(s) Too Large
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!
49 Replies
Project ID:
4b7ea996-5769-4729-abf5-aba577a03dd8
please send a link that show this error
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
Please let me know if you need any further informationWe 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? just on
https://app.zigma.io/dashboard/
i do not see any fetch reqs that are failingcan 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 🤔
to be perfectly honest with you, thats unfortunately not a very compressive test
just on https://app.zigma.io/dashboard/ i do not see any fetch reqs that are failingDid 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
issuegotcha
nope no errors still
to be perfectly honest with you, thats unfortunately not a very compressive testYou're right, since this issue is quite tricky and first time encountering it 😢 any suggestions would be greatly appreciated
have you tried running your site locally and sending artificially large headers to your app via curl or postman?
no errors here too, even when going to main dashboard or main page
you could try in a incognito window?
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
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)
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 testThank you for your response, unfortunately, similar issues are also occurring with some new users with diff browsers
What’s confusing now is where this response is coming from 🤔
can you attempt the same test with this - https://utilities.up.railway.app/raw
with the same request headers?
yep
send headers as big or bigger than what you send to your production app when you are getting that 431
after testing step by step, the response is consistently successful
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? 🤔your domain is behind cloudflare right?
Yeah, but DNS only
i have additional logging in place, can you try it again?
Just tried
send the headers here please
these are the headers from the minimal issue isolation
what about the cookie? there is no way thats all the headers
right but that request would also include cookies?
yes, my bad. the default
credentials
is same-origin
, so cookies will be includedplease send the same sized headers to that link
sent
200?
yeah, getting 200 with total 8.22KB content
7682 bytes of just headers, and cookie itself is only 6395 bytes
I don't think you are replaying the request to my endpoint correctly, those are miniscule sizes
I can confirm that I included all the headers from the 431 request, I've double-checked each request header
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.im not able to do that right now, sorry
Is there a way to specify the Node version for the Nixpacks builder? 👀
How can I request to view the complete HTTP logs? 👀
im sorry but that request is not something we can fulfil right now
It looks like the node version isn't following the
NIXPACKS_NODE_VERSION
🤔why do you say that? it says node 20 in that table
will it use the same minor version as
NIXPACKS_NODE_VERSION
? 🤔Only a major version can be specified. For example, 18.x or 20.
Is there any way to determine if these 431 requests have reached Railway?
does your app itself not log requests?
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)
railway would return a plaintext response when you exceed the header limit size, you have since shown me an html page
New reply sent from Help Station thread:
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)Do I need to provide any other information for this?You're seeing this because this thread has been automatically linked to the Help Station thread.
Please open your own thread, OP was not running into any Railway limitations, but you might be.