What a 413 Request Entity Too Large error means
A 413 error means a server refused your request because the body was bigger than it is set to accept. It almost always happens during an upload: a large image, a video, a theme or plugin zip, a database import or a big JSON payload sent to an API. The fix is to find which layer sent the 413 and raise the limit on that layer, plus every layer behind it.
The name has changed over the years. RFC 2616 called it "Request Entity Too Large", RFC 7231 renamed it "Payload Too Large", and RFC 9110, the current HTTP standard, calls it "413 Content Too Large". All three names mean the same status code, and servers still print whichever name they were built with.
Which layer sent the 413?
A request can pass through several pieces of software before it reaches your code, and each one can have its own size limit. The lowest limit on the path wins.
- A CDN or proxy in front, such as Cloudflare. If the error page carries Cloudflare's branding, the request never reached your server.
- The web server: Nginx, Apache or LiteSpeed. Nginx's default error page shows "413 Request Entity Too Large" with "nginx" underneath.
- PHP. When a PHP limit is exceeded, the request usually reaches your site and the application reports an error, for example WordPress saying the file "exceeds the upload_max_filesize directive in php.ini", instead of a bare 413 page.
- The application itself, such as a Node.js app whose body parser rejects large payloads with a 413.
Open your browser's developer tools, go to the Network tab and look at the failing request. The response headers and body usually name the server. Nginx's documentation also warns that browsers cannot always display this error correctly, so an upload form may just stall or show a generic failure.
| Layer | Setting | Default | Where to change it |
|---|---|---|---|
| Nginx | client_max_body_size | 1m | http, server or location block |
| Apache 2.4 | LimitRequestBody | 1073741824 bytes (1 GiB) in current releases; 0 (unlimited) in 2.4.53 and earlier | Server config, virtual host, directory or .htaccess |
| PHP | upload_max_filesize | 2M | php.ini, .user.ini, or .htaccess when PHP is an Apache module |
| PHP | post_max_size | 8M | Same as above |
| Cloudflare | Maximum Upload Size | 100 MB on Free and Pro, 200 MB on Business, up to 5 GB on Enterprise | Set by the plan |
| Express (Node.js) | limit on express.json() and express.urlencoded() | 100kb | Application code |
The PHP defaults are the values in PHP's own manual. Hosting companies and Linux distributions often ship different values, so always check what your server is actually using.
Quick checklist
- Note the exact size of the file or request that fails, and the exact error text.
- Find which layer answered: CDN, web server, PHP or the app.
- Raise the limit on that layer to a little above the size you need, not to unlimited.
- Raise every layer behind it too. A bigger Nginx limit does not help if PHP still stops at 2M.
- Reload the service, or wait for cached settings to expire.
- Test the upload again and confirm the new values took effect.
Nginx: client_max_body_size
Nginx checks the size of every request body against client_max_body_size. The default is 1m, which is too small for most media uploads, so this is the most common cause of a 413 on a VPS running Nginx. The directive is allowed in the http, server and location contexts. Setting it to 0 disables the check, which is not a good idea on a public site.
To raise it for one site, add it to that site's server block, for example in /etc/nginx/sites-available/example.com on Ubuntu:
server {
server_name example.com;
client_max_body_size 64m;
# rest of the server block
}
To allow large bodies only on an upload endpoint, put it in a location block instead, such as location /api/upload. To change it for every site on the server, put it in the http block of /etc/nginx/nginx.conf. A value in a more specific block overrides the one above it.
Test the configuration, then reload Nginx so it picks up the change without dropping connections:
sudo nginx -t
sudo nginx -s reload
On a systemd distribution such as Ubuntu, sudo systemctl reload nginx does the same job. If Nginx passes PHP requests to PHP-FPM, raise the PHP limits as well (see below).
Apache: LimitRequestBody
Apache's LimitRequestBody sets the maximum request body in bytes, and 0 means unlimited. The Apache documentation records that the default changed: in 2.4.53 and earlier it was 0 (unlimited), and current 2.4 releases default to 1073741824 bytes, which is 1 GiB. So a server that never had a body limit can start refusing very large uploads after an upgrade, and a hosting company or control panel may also have set a lower value.
The directive works in the server config, a virtual host, a <Directory> section or .htaccess. For example, to allow up to 100 MiB in one folder:
<Directory "/var/www/example.com/uploads">
LimitRequestBody 104857600
</Directory>
Check the syntax and reload Apache on Ubuntu or Debian:
sudo apachectl configtest
sudo systemctl reload apache2
The value is in bytes, not megabytes. Writing 100 means 100 bytes, which would break almost every form on the site.
PHP: upload_max_filesize, post_max_size and memory_limit
For PHP sites, including WordPress, three settings control uploads:
upload_max_filesize: the largest single uploaded file. PHP's default is 2M.post_max_size: the largest whole POST request, including all files and form fields together. PHP's default is 8M. The PHP manual says it must be larger thanupload_max_filesize. If the POST data is bigger than this,$_POSTand$_FILESarrive empty.memory_limit: the most memory one script may use. PHP's default is 128M, and the manual says that, generally speaking, it should be larger thanpost_max_size.
There is also max_file_uploads, the number of files allowed in one request, which defaults to 20. The three size settings above accept the shorthand K, M and G.
upload_max_filesize and post_max_size have the mode INI_PERDIR. That means they can be set in php.ini, .htaccess, httpd.conf or .user.ini, but not with ini_set() inside a script. A line of PHP code in your application cannot raise them.
On cPanel: MultiPHP INI Editor
- Log in to cPanel and open Software > MultiPHP INI Editor.
- In Basic Mode, choose the domain from the menu, or Home Directory to apply the change to all your sites.
- Set
upload_max_filesize, then setpost_max_sizeto a higher value, and adjustmemory_limitif needed. - Click Apply.
cPanel writes the change to php.ini, .user.ini and .htaccess, in each file only where that file supports the directive.
By hand: php.ini or .user.ini
On your own server, edit the php.ini that the web server uses. With PHP-FPM on Ubuntu or Debian that is /etc/php/<version>/fpm/php.ini, for example /etc/php/8.3/fpm/php.ini on Ubuntu 24.04, whose default PHP is 8.3. Newer releases ship a newer PHP, so check your version first with php -v or ls /etc/php. The php --ini command shows the command-line configuration, which can be a different file, so confirm the "Loaded Configuration File" line in a phpinfo() page served through the web server. Then set, for example:
upload_max_filesize = 64M
post_max_size = 72M
memory_limit = 256M
Restart PHP-FPM with sudo systemctl restart php8.3-fpm, changing 8.3 to the version you found. Delete any phpinfo() file once you are done, because it exposes server details.
Where PHP runs as CGI or FastCGI, you can also put the same lines in a .user.ini file in the site's folder. PHP re-reads these files every 300 seconds by default (user_ini.cache_ttl), so a change can take up to five minutes to show. If PHP runs as an Apache module instead, use php_value lines in .htaccess. Our PHP guide explains how to check and change the PHP version.
WordPress: media, theme and plugin uploads
WordPress shows the current limit on Media > Add New Media File as "Maximum upload file size". That figure comes from PHP: WordPress takes the smaller of upload_max_filesize and post_max_size. The same limit applies when you upload a theme or plugin zip from the dashboard.
Two common mistakes:
- Editing wp-config.php.
WP_MEMORY_LIMITinwp-config.phponly sets how much memory WordPress asks for. It does not raise the upload limit, and because the upload settings areINI_PERDIR, anini_set()line there cannot either. Change the PHP settings as described above. - Raising only upload_max_filesize. If
post_max_sizestays smaller, large uploads still fail. WordPress may then report that the file is empty and suggest thatpost_max_sizeis smaller thanupload_max_filesize.
If the dashboard upload fails with a 413 page rather than a WordPress message, the web server or a CDN stopped it before PHP saw it. For a large theme or plugin you can also skip the browser: upload the zip over SFTP or cPanel's File Manager and extract it into wp-content/themes or wp-content/plugins.
Proxies, CDNs and Node.js apps
Cloudflare and other CDNs
When a domain is proxied through Cloudflare, Cloudflare enforces its own upload limit before the request reaches your server. Its documentation lists 100 MB on the Free and Pro plans, 200 MB on Business, and up to 5 GB on Enterprise. Larger requests get a 413 from Cloudflare, and no setting on your server changes that.
Cloudflare suggests three ways around it: split the upload into smaller requests if your application supports that, set the DNS record used for uploads to DNS-only so it is not proxied, or move to a higher plan. Our guide to what a CDN is explains proxying in more detail. Other reverse proxies and load balancers have their own limits too, so check every hop.
Node.js and Express
Express's express.json() and express.urlencoded() middleware reject bodies over their limit option, which defaults to 100kb. The error has status 413 and type entity.too.large. Raise it to what your API really needs:
app.use(express.json({ limit: '5mb' }));
Keep the limit modest. Large JSON bodies cost memory and time to parse, and files are better sent as multipart uploads. If Nginx sits in front of the app, its client_max_body_size must be at least as large as the app's limit, or Nginx answers with a 413 first. If Nginx instead reports that the app failed, see the 502 Bad Gateway guide.
Fixing a 413 on Bigdomainhost hosting
Bigdomainhost's Web & cPanel hosting and WordPress hosting run on LiteSpeed with cPanel, on servers in Mumbai. Change the PHP upload settings for each domain in the MultiPHP INI Editor as described above. If a 413 continues after that, the limit is probably set at the web server or at a CDN such as Cloudflare in front of the site. Check the error page first. If it is not a CDN's page, send the domain name and the file size to support on WhatsApp at +91 75994 50220 at any time, or call the same number in IST working hours.
On a KVM VPS you have full root access, so you set the Nginx, Apache and PHP limits yourself. Servers are in Mumbai and Delhi NCR and are prepaid in 30-day periods.
This guide was drafted with AI assistance and checked against the official documentation listed in the sources on 23 November 2026.
Sources (checked )
- nginx: Module ngx_http_core_module: client_max_body_size
- Apache HTTP Server: Apache Core Features: LimitRequestBody
- PHP Manual: Description of core php.ini directives
- cPanel Docs: MultiPHP INI Editor for cPanel
- Cloudflare Docs: Error 413
- IETF: RFC 9110: HTTP Semantics, 413 Content Too Large
- Express: express() API: express.json() and express.urlencoded()
- Express: body-parser middleware: errors