413 Request Entity Too Large

nedensinir
HOBBY

6 days 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?

Solved

0 Replies

6 days ago

I wonder if it's a configuration within your code and or whatever web framework you're using <:Thinking:1360710341239242762>


6 days ago

N/A


nedensinir
HOBBY

6 days ago

I am using nestjs


nedensinir
HOBBY

6 days ago

I didnt set anything


nedensinir
HOBBY

6 days ago

its working fine on my machine


6 days ago

what do you use to parse requests?


nedensinir
HOBBY

6 days ago

basic fetch api


6 days ago

no no, on your server


nedensinir
HOBBY

6 days ago

I get this error when I try to use fetch


nedensinir
HOBBY

6 days ago

somewhere in the app


nedensinir
HOBBY

6 days ago

not when I try to response


nedensinir
HOBBY

6 days ago

I think thats what you mean if not sorry I didnt get the question


6 days 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


nedensinir
HOBBY

6 days ago

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

1394657070887993300


6 days ago

what other server? is it your server or a server someone else owns?


nedensinir
HOBBY

6 days ago

no basically I make another request to some other origin


nedensinir
HOBBY

6 days ago

and I put 1000 strings (each 64 bytes) and it complains about that body


nedensinir
HOBBY

6 days ago

its not a problem of me parsing the ongoing request to my server


nedensinir
HOBBY

6 days ago

its a problem that occurs when I try to make a request from my server to other API


6 days ago

what other API? is it your API or an API someone else owns?


nedensinir
HOBBY

6 days ago

no its an RPC that is owned by someone else


nedensinir
HOBBY

6 days ago

````
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

```


nedensinir
HOBBY

6 days ago

I just got this error on my railway log


6 days 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"


nedensinir
HOBBY

6 days ago

no I really dont thing thats an issue on their part


nedensinir
HOBBY

6 days ago

it works fine


nedensinir
HOBBY

6 days ago

on my local machine


nedensinir
HOBBY

6 days ago

when I run the server


nedensinir
HOBBY

6 days ago

its something that railway blocks me from sending a request that has body size which is bigger than X


6 days ago

I assure you it's not something Railway is blocking, it's something the other API server you mention is blocking


nedensinir
HOBBY

6 days ago

Okay then why am I not getting the same error when I use it on my local


6 days ago

I'm not sure, maybe you send different data when testing it locally


nedensinir
HOBBY

6 days ago

no its exactly the same data


nedensinir
HOBBY

6 days ago

same configs


nedensinir
HOBBY

6 days ago

I really think its something with nginx configurations


6 days 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?


nedensinir
HOBBY

6 days ago

I mean I guess because I am really stuck and I have to figure this out


6 days ago

Alright, then I'll get back to you once I get a response


nedensinir
HOBBY

6 days ago

thanks a lot


6 days ago

no problem 🙂


6 days 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).


nedensinir
HOBBY

6 days ago

okay I see but I still dont understand why does this work on mine


nedensinir
HOBBY

6 days ago

without any problem


6 days 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


nedensinir
HOBBY

6 days ago

Okay I see thanks a lot for the help and time


6 days ago

Happy to help, best of luck


4 days ago

!s


Status changed to Solved dev 4 days ago


413 Request Entity Too Large - Railway Help Station