8 months ago
Hi Railway team,
I’m encountering a 413 Payload Too Large error when uploading large files to my Railway backend only in production.
Details:
- Backend hosted on Railway
- Frontend works correctly from localhost → Railway backend with same files.
- When frontend is deployed and hits the same Railway backend, file upload returns 413
- Small requests work; only large file uploads fail
- Backend logs show the request does not reach the application when uploading large files.
This makes me suspect a proxy or request body size limit on the Railway edge or runtime.
Could you please confirm:
- Whether Railway enforces request/body size limits for incoming uploads
- If so, what the current limits are and whether they’re configurable
Thanks in advance.
Best regards,
Awa
1 Replies
13 days ago
it works from localhost, so railway's edge isn't what's capping the body. same file, same backend, same edge. what changes is the deployed frontend: its requests are going through a proxy on the frontend side, and that's what returns the 413 before anything reaches your backend.
check the failing request in devtools. if the url is your frontend's domain (/api/...) and not the backend's railway url, that's it.
fix depends on the proxy:
- nginx: add
client_max_body_size 50m;(default is 1m) - vercel rewrites/api routes: hard 4.5mb limit, upload straight to the backend url instead (enable cors)
- next server actions: raise
serverActions.bodySizeLimit(default 1mb)