Why do file uploads fail with 413?
The default client_max_body_size in Nginx is 1 MB. Add client_max_body_size 20M (or whatever size your app needs) to the server block or http block in nginx.conf.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Nginx Common Configuration Mistakes and How to Fix Them
The Upgrade and Connection headers are missing. Add proxy_http_version 1.1, proxy_set_header Upgrade $http_upgrade, and proxy_set_header Connection 'upgrade' to the location block. These are required for the WebSocket protocol upgrade from HTTP.
Nginx is not passing the real client IP. Add proxy_set_header X-Real-IP $remote_addr and proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for. Also set app.set('trust proxy', 1) in Express so it reads the X-Forwarded-For header.
Nginx is not configured with try_files. Add try_files $uri $uri/ /index.html to the location block. This tells Nginx to fall back to index.html for any path that doesn't match a static file, enabling client-side routing.
Still have questions?
Browse all our FAQs or reach out to our support team
