8 months ago
Hello I get the following error when I depoly my app to railway:
Attempt 5/6 failed: 413 Request Entity Too Large: request body size exceeds allowed maximum
Is there a way to increase this or do I have to adapt my code?
47 Replies
8 months ago
I wonder if it's a configuration within your code and or whatever web framework you're using <:Thinking:1360710341239242762>
8 months ago
N/A
8 months ago
what do you use to parse requests?
8 months ago
no no, on your server
8 months ago
when you make a request to your server, your server receives the request and parses it to make it understandable, typically you have some sort of parser like body-parser or a json parser to make sense of the request, and these parsers often have preset limits that you can increase - my theory is that, since you said you didn't set anything, you likely haven't changed the default limit on these meaning that your body size could exceed the predefined limit; the solution here would be to increase the limit
yeah okay I have bodyParser I set its limits to 50 mb
but what I am saying is I get this error when I try to send a request to some other server within my server. I attach 1k strings to the request for that other server and I think it blocks me from sending because of 1k strings

8 months ago
what other server? is it your server or a server someone else owns?
and I put 1000 strings (each 64 bytes) and it complains about that body
its a problem that occurs when I try to make a request from my server to other API
8 months ago
what other API? is it your API or an API someone else owns?
````
Attempt 1/6 failed: 413 Request Entity Too Large: request body size exceeds allowed maximum
Attempt 1/6 failed. Retrying in 200ms
Attempt 2/6 failed: 413 Request Entity Too Large: request body size exceeds allowed maximum
Attempt 2/6 failed. Retrying in 400ms
Attempt 3/6 failed: 413 Request Entity Too Large: request body size exceeds allowed maximum
Attempt 3/6 failed. Retrying in 800ms
Attempt 4/6 failed: 413 Request Entity Too Large: request body size exceeds allowed maximum
Attempt 4/6 failed. Retrying in 1600ms
Attempt 5/6 failed: 502 Bad Gateway:
502 Bad Gateway
nginx/1.26.2
```
8 months ago
If it's someone elses server then they'd need to increase the request limit or you'd need to send less data
unfortunately there's nothing Railway can do about this cause its not within Railway's control what that other API server deems as "too large"
its something that railway blocks me from sending a request that has body size which is bigger than X
8 months ago
I assure you it's not something Railway is blocking, it's something the other API server you mention is blocking
Okay then why am I not getting the same error when I use it on my local
8 months ago
I'm not sure, maybe you send different data when testing it locally
8 months ago
I can check with a Railway team member if you want me to, but I'm very confident Railway doesn't interfere with your requests
would you like me to check with a team member?
8 months ago
Alright, then I'll get back to you once I get a response
8 months ago
no problem 🙂
8 months ago
Alright, team member got back to me and confirmed what I was saying,
He explained that a 413 status code is on layer 7 (of the OSI model), this is the layer that holds all application-level protocols (HTTP, FTP, SSH, SMTP). When your container on Railway makes a request, the request leaving the container is only operating on layer 3 (holding lower-level protocols like IP, and ICMP), naturally on this layer there is no such thing as status codes because status codes (like 413, the error you're seeing) is a concept that only exists on HTTP (which is on layer 7).
Since Railway only handles traffic up until layer 3, there is no way for Railway to respond with a 413 status code because that doesn't happen until you reach layer 7 and by the time your request reaches layer 7 your request would be far out of Railway's reach.
In conclusion, it not only means Railway doesn't interfere with your requests (like I was saying), but it also means Railway couldn't interfere with your request (in the same way you're seeing) even if they wanted to. Ultimately meaning that it is definitely the server you're trying to reach responding with 413, which means you should talk to the developers and or support behind that server (or send less data).
8 months ago
It's hard to say, but you should really talk to them if you want to get to the bottom of it because Railway is definitely not interfering with the request. For all we know they could be adjusting the upload limit depending on whether the IP is a residential or datacentre IP address, you'll never know unless you ask
8 months ago
Happy to help, best of luck
8 months ago
!s
Status changed to Solved dev • 8 months ago