Uploads larger than 1 MB fail with 413 behind the Kubernetes NGINX Ingress controller
413 Request Entity Too LargeShort answer
The ingress-nginx controller limits request bodies to 1m by default and answers 413 above that. Raise the limit with the nginx.ingress.kubernetes.io/proxy-body-size annotation on the Ingress that serves the upload route, or set the proxy-body-size key in the controller ConfigMap to change the default for every Ingress.
Fix it fast
1Find out which cause you have
Send a file just over 1 MB through the Ingress host and read the status line. A 413 from nginx means the body-size limit, not your application.
head -c 2000000 /dev/zero > big.bin && curl -i -F file=@big.bin https://example.com/upload2Match what you see, then jump to its fix
- 1
413 comes from nginx and the Ingress has no proxy-body-size annotationThe default proxy-body-size of 1m applies to this IngressFix - 2
Many services need larger uploads and each Ingress hits 413You want a new default for every Ingress in the clusterFix - 3
The annotation exists but 413 continuesThe annotation key is wrong or sits on the wrong objectFix
- 1
What does the error look like?
413 Request Entity Too LargeUploads of a few MB fail, small files work
Cause 1 of 3
The default proxy-body-size of 1m applies to this Ingress
1Check
The controller documentation lists a default of 1m for the proxy-body-size setting, and says a 413 is returned when a request exceeds the allowed size.
kubectl get ingress my-ingress -n my-namespace -o yaml2Fix
Add the annotation to the Ingress that serves the upload path, with a size above your largest file.
kubectl annotate --overwrite ingress my-ingress -n my-namespace \
nginx.ingress.kubernetes.io/proxy-body-size=50m3Verify
Repeat the upload; the status is no longer 413.
curl -i -F file=@big.bin https://example.com/uploadConfirmed by kubernetes.github.io
Cause 2 of 3
You want a new default for every Ingress in the cluster
1Check
proxy-body-size is also a key of the controller ConfigMap, where the default is 1m. An annotation on one Ingress overrides it for that Ingress only.
kubectl get configmap -n ingress-nginx2Fix
Set the key in the ConfigMap that your controller reads. Its name depends on how the controller was installed, so find it first.
# controller ConfigMap
data:
proxy-body-size: "50m"3Verify
Repeat the upload test against a different Ingress that has no annotation.
curl -i -F file=@big.bin https://example.com/other-uploadConfirmed by kubernetes.github.io
Cause 3 of 3
The annotation key is wrong or sits on the wrong object
1Check
The exact key is nginx.ingress.kubernetes.io/proxy-body-size, a string value such as 8m, and it belongs on the Ingress object that routes the failing path, not on the Service or Deployment.
kubectl get ingress -A | grep example.com2Fix
Set the exact key with kubectl annotate on the right Ingress. kubectl refuses to change an existing annotation unless --overwrite is given.
kubectl annotate --overwrite ingress my-ingress -n my-namespace \
nginx.ingress.kubernetes.io/proxy-body-size=50m3Verify
Upload the large file again.
curl -i -F file=@big.bin https://example.com/uploadConfirmed by kubernetes.io
How do I stop it coming back?
- Decide an upload limit per route and set it on that route's Ingress in the manifest, not by hand.
- Keep the same limit in the application (for example its own body-size setting) so one layer does not reject first.
- Add a large-file upload to your post-deploy smoke test.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Servers
Argo CD behind an nginx Ingress loops with too many redirects
307 Temporary Redirect on every request to the Argo CD host
The browser and Argo CD disagree about who handles TLS.
3 causes, each with a fixServers
ingress-nginx controller stops working after upgrading Kubernetes to 1.22 or later
ingress-nginx controller does not start after an AKS upgrade to 1.22
Kubernetes 1.22 stopped serving the extensions/v1beta1 and networking.k8s.io/v1beta1 Ingress APIs.
2 causes, each with a fixServers
Kubernetes Ingress returns 404 for a path other than /
404 Not Found nginx on /app but / works
The ingress matches /app, but the backend still receives /app and has no route there, so it answers 404.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
A cert-manager Certificate stays at READY False with Let's Encrypt
Issuing certificate as Secret does not exist
A Certificate that stays not ready is waiting on a chain: Issuer, CertificateRequest, Order, Challenge.
3 causes, each with a fixServers
A Let's Encrypt certificate did not renew with Certbot
Type: connection ... Timeout during connect (likely firewall problem)
Run sudo certbot renew --dry-run and read the Type and Detail lines.
6 causes, each with a fix