WordPress in Docker keeps the old upload size limit
Uploads over 2 MB fail in the media library although you edited php.ini inside the containerShort answer
The wordpress image runs stock PHP, whose default upload limit is 2M with an 8M POST cap. Put your own ini file into the image's conf.d directory, keep post_max_size above upload_max_filesize, and rebuild. If a reverse proxy sits in front, raise its body-size limit as well; nginx stops at 1m.
Fix it fast
1Find out which cause you have
Ask PHP inside the running container which values it really uses. If they are still the defaults, the ini file did not reach the image.
docker compose exec wordpress php -i | grep -E "upload_max_filesize|post_max_size|memory_limit"2Match what you see, then jump to its fix
- 1
The command above prints upload_max_filesize => 2M and post_max_size => 8MNo custom ini file in the image's conf.d directoryFix - 2
upload_max_filesize looks right, yet big files fail and $_POST and $_FILES arrive emptypost_max_size or memory_limit is smaller than the file limitFix - 3
413 Request Entity Too Large from nginx, before PHP sees the requestA reverse proxy in front rejects the bodyFix
- 1
What does the error look like?
Uploads over 2 MB fail in the media library although you edited php.ini inside the container413 Request Entity Too LargeLarge upload returns to the form with empty $_POST and $_FILES
Cause 1 of 3
No custom ini file in the image's conf.d directory
1Check
PHP's defaults are upload_max_filesize 2M and post_max_size 8M. Edits made by hand in a running container are lost when it is recreated. The official image reads extra ini files from $PHP_INI_DIR/conf.d/.
docker compose exec wordpress bash -c 'ls $PHP_INI_DIR/conf.d/'2Fix
Create custom.ini, copy it into conf.d in a small Dockerfile, and make Compose build that image.
# custom.ini
upload_max_filesize = 64M
post_max_size = 72M
memory_limit = 256M
# Dockerfile
FROM wordpress:latest
COPY custom.ini $PHP_INI_DIR/conf.d/
# compose.yaml (wordpress service)
build: .3Verify
Rebuild, recreate and print the values again.
docker compose up -d --build
docker compose exec wordpress php -i | grep -E "upload_max_filesize|post_max_size"Confirmed by hub.docker.com
Cause 2 of 3
post_max_size or memory_limit is smaller than the file limit
1Check
A file upload travels inside the POST body, so post_max_size has to be larger than upload_max_filesize, and memory_limit should be larger than post_max_size. When the POST body is too big, PHP drops $_POST and $_FILES silently.
docker compose exec wordpress php -i | grep -E "upload_max_filesize|post_max_size|memory_limit"2Fix
Keep the order memory_limit > post_max_size > upload_max_filesize in custom.ini, rebuild, and retry.
upload_max_filesize = 64M
post_max_size = 72M
memory_limit = 256M3Verify
The three values print in that order of size.
docker compose up -d --buildConfirmed by php.net
Cause 3 of 3
A reverse proxy in front rejects the body
1Check
nginx allows a 1m request body by default, no matter what PHP allows. If nginx proxies to the WordPress container, requests above 1 MB end with 413.
grep -rn client_max_body_size /etc/nginx/2Fix
Set client_max_body_size in the server block that proxies to WordPress, equal to or above upload_max_filesize.
server {
client_max_body_size 64m;
}3Verify
Test the config, reload nginx, upload again.
sudo nginx -t && sudo systemctl reload nginxConfirmed by nginx.org
How do I stop it coming back?
- Keep custom.ini in the project repository and build the image from it, so a recreated container never loses the settings.
- Change the PHP limits and the proxy limit in the same commit.
- Set limits to the size you actually need instead of a huge number.
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
Web apps
WordPress media upload fails with "Unexpected response from the server"
413 Request Entity Too Large
WordPress shows this message when the upload request did not come back as the JSON it expects.
3 causes, each with a fixServers
Docker php image has no php.ini and my edits do not stay
A setting changed in php.ini inside the container is gone after the container is recreated
The official php image ships php.ini-development and php.ini-production but no active php.ini.
2 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
docker-php-ext-install mbstring fails: oniguruma not found
The docker-php-ext-install step exits with a non-zero code
mbstring needs the Oniguruma library to build its regex functions, and the PHP build finds it through pkg-config.
3 causes, each with a fixServers
HTTP 414 error: the web server says the URL is too long
414 Request-URI Too Large
A 414 means the server refused the request because the URL is longer than it accepts.
4 causes, each with a fixServers
The MinIO Console will not work behind an nginx proxy: no login, 403 on the WebSocket, or repeated disconnects
The Console UI shows repeated disconnects
Behind a proxy the MinIO Console needs three things.
4 causes, each with a fix