413 Request Entity Too Large: How to Raise Upload Limits in Nginx, Apache and PHP

Short answer
What does 413 Request Entity Too Large mean?
413 Request Entity Too Large is an HTTP status code a server returns when the request body exceeds its configured limit. First, the browser starts sending the file; then the server sees the size, and it turns the request away without processing it. The file is not broken; it is simply over the limit.
Short answer: 413 Request Entity Too Large means the server rejected your request, usually a file upload, because it was larger than the size it allows. The fix is to find the layer that sets the limit and raise it only there: client_max_body_size in Nginx, LimitRequestBody in Apache, and upload_max_filesize plus post_max_size in PHP.
In this guide we first show how to tell which layer the error comes from, then how to change the limit in each one. There are separate sections for cPanel users on shared hosting and for anyone who cannot upload to the WordPress media library. That way you change the right setting instead of guessing.
According to MDN, the current name of this code is Content Too Large, and the older name was Payload Too Large; that was the official phrase before RFC 9110, and many servers still show it. You can read the definition on the MDN 413 page. Whatever name you see on screen, the meaning stays the same.
Above all, the key thing about this error is that the limit does not live in one place. A request passes through several layers before it reaches your app, and each layer can apply its own size limit. That is why raising the limit in one layer and still seeing the error is so common. The real job is finding the layer that stops the request.
Which layer is causing the 413 error, and how do you tell?
A file upload usually travels in this order: the browser, then a CDN or security layer if you have one, then the web server (Nginx or Apache), then PHP, and finally the app, for example WordPress. So how the error looks is your first clue to the right layer.
- A plain, unbranded page saying "413 Request Entity Too Large" with "nginx" underneath most likely means the limit sits in Nginx.
- An Apache branded error page points you to the LimitRequestBody setting.
- A warning inside WordPress saying the file exceeds a size limit usually means the limit is on the PHP side.
- An upload that fails silently and returns an empty form may mean post_max_size kicked in.
- An error page in your CDN or security service's own design means the limit sits in that layer.
The Nginx documentation adds an interesting note: browsers cannot always display this error correctly. So sometimes you see a stalled upload or a generic connection error instead of a proper error page. In that case, checking the status code in the network tab of your browser's developer tools is the most reliable move.
Nginx vs Apache vs PHP limits: comparison table
The table below shows the main settings that affect upload size, where they live and what you see when you exceed them. Defaults change with versions and hosting providers, so check the current value in the official docs and on your own server.
| Layer | Setting | Official default | When exceeded |
|---|---|---|---|
| Nginx | client_max_body_size | 1m | Returns 413 Request Entity Too Large. |
| Apache | LimitRequestBody | 1 GiB (2.4.54 and later) | Returns an error instead of serving the request. |
| PHP file | upload_max_filesize | 2M | The app shows a file size error. |
| Form data | post_max_size | 8M | Form data and files arrive empty. |
| PHP memory | memory_limit | 128M | A memory error may appear during processing. |
In practice, we took these values from the Nginx, Apache and PHP documentation. However, hosting providers often change them for their plans. For example, the PHP upload limit on a shared plan may differ a lot from the default. So treat the table as a starting point and read the real value on your own server.
How do you fix 413 Request Entity Too Large in Nginx?
According to the Nginx docs, client_max_body_size sets the maximum allowed size of the client request body. When a request exceeds it, Nginx returns 413. The default is 1 megabyte, and setting it to 0 disables the size check entirely. You can see the details in the Nginx core module documentation.
Also, you can set this directive at three levels: in the http block for all sites, in a server block for one site, or in a location block for a single path. Our advice is to raise the limit in the narrowest place possible. For example, giving only the admin upload path a higher limit is safer than opening the whole site to large requests.
- Find the matching server or location block in your site's Nginx config.
- Add or update the client_max_body_size line with a size that fits your needs.
- Validate the config with Nginx's test command.
- If the test passes, reload Nginx.
- Upload the same file again and check the result.
If PHP runs behind Nginx, raising the Nginx limit alone may not be enough. The request passes Nginx, then hits the PHP limit. Therefore you need to keep the Nginx limit in line with post_max_size on the PHP side.
How do you change LimitRequestBody in Apache?
According to the Apache docs, LimitRequestBody sets the number of bytes allowed in a request body, and a value of 0 means unlimited. The docs also state that the default is 1 GiB from version 2.4.54 on; in 2.4.53 and earlier, the default was 0, which means unlimited. You can find this in the Apache core documentation.
In addition, you can set it in the server config, a virtual host, a directory block or an .htaccess file. On shared hosting you often only have .htaccess access. In that case the setting applies to that directory and its subdirectories.
One important detail about Apache: on newer versions, the default limit is already quite high. So if an Apache site shows a 413, either someone lowered the value on purpose, or the limit lives in another layer. First, search the existing config and your .htaccess files for a LimitRequestBody line.
- Check the value in the main config and in the virtual host block.
- Look at the .htaccess files in the site root and the upload directory.
- If Nginx sits in front as a reverse proxy, the real limit may be there.
How do you set PHP upload_max_filesize and post_max_size together?
On this side, then, two settings work as a pair. upload_max_filesize is the maximum size of a single uploaded file. post_max_size is the total limit for all data a form sends. According to the PHP docs, post_max_size must be larger than upload_max_filesize to upload large files.
The same page adds two more important notes. First, memory_limit should generally be larger than post_max_size. Second, if the posted data exceeds post_max_size, PHP leaves the form data and file arrays empty. You can read the full page in the PHP core configuration docs.
Moreover, that last point is very valuable for diagnosis. When the PHP limit trips, the server does not always return 413; instead the app receives an empty form and produces its own error. In other words, if you see no 413 but the upload still fails, post_max_size is often the first suspect.
- First, find the size of the largest file you need to upload.
- Set upload_max_filesize slightly above that size.
- Keep post_max_size larger than upload_max_filesize.
- Check that memory_limit does not sit below post_max_size.
How do you raise the upload limit with cPanel MultiPHP?
On shared hosting, you usually reach PHP settings through the control panel rather than server files. On cPanel plans, the MultiPHP INI Editor or a similar PHP selector from your host handles this. Screen names differ between hosts, so we suggest searching for "PHP" inside the panel.
On that screen you first pick your domain and change upload_max_filesize, post_max_size and memory_limit. The panel usually writes the change into that domain's PHP config file. Then you try the upload again. Also remember that switching PHP versions can reset some settings; we explain how the version screen works in our guide to changing the PHP version in cPanel.
Some plans do not let you go above the cap the plan allows. If you save a value and nothing changes, your host's cap is in play. We cover these invisible shared hosting limits in our article on whether unlimited hosting is really unlimited. For the general logic of resource caps, our guide to shared hosting resource limits also helps.
How do you fix 413 Request Entity Too Large in WordPress media uploads?
The WordPress media library usually shows the upload limit on screen. That number, however, comes from PHP settings. However, even when WordPress shows a high limit, a low Nginx limit in front sends large files back with a 413. That is why the number on the WordPress screen alone is not proof.
When fixing this error in WordPress, we suggest this order:
- Note the maximum upload size shown in the media library.
- If your file is below that limit, the problem most likely sits in the web server.
- When your file is above that limit, raise the PHP values first.
- If the server runs Nginx, align client_max_body_size with the PHP values.
- Test for a plugin based upload restriction by disabling the plugin temporarily.
If you see a white screen or a generic error after the upload finishes, the issue is no longer size but processing. For that case, see our guide to the WordPress critical error. We look at memory errors during large image processing separately in our PHP allowed memory size exhausted guide.
How do you tell a 413 from other upload errors?
Put simply, not every failed upload is a 413. Mixing up different errors leads you to change the wrong setting. The table below separates the cases people confuse most often.
| Symptom | Likely cause | Where to look |
|---|---|---|
| Status 413, plain error page. | Web server or middle layer size limit. | client_max_body_size, LimitRequestBody, CDN. |
| File size warning inside the app. | PHP file limit. | upload_max_filesize. |
| Form returns empty, no message. | Total data limit. | post_max_size. |
| Upload runs long, then times out. | Time limit or slow connection. | Server and PHP timeout settings. |
| Upload finishes, then a white screen. | Memory or code error during processing. | memory_limit and the error log. |
The most reliable source for this distinction is your browser's developer tools. In the network tab, pick the upload request and check its status code. If the code is 413, the problem is a size limit. If the code is 200 but the action still fails, the problem lives in the app or PHP. Also, the server header in the response shows which software answered the request.
In short, "the upload doesn't work" is not a diagnosis on its own. When you note the status code, the look of the error page and the file size together, you rule out most causes in the first minute.
Is it better to shrink the file than raise the limit?
Not every 413 calls for a higher limit. With image uploads especially, the file is often far larger than needed. A raw photo from a phone is much bigger than the size a web page actually displays. In that case, raising the limit just adds unnecessary weight to your site.
Resizing images before upload both fixes the error and protects page speed. You can bring the width down with our image resizer, then switch to a lighter format with the JPG to WebP converter. As a result, the same image goes live as a much smaller file.
Video, on the other hand, is a little different. Uploading large video files to your own server both pushes limits and eats hosting resources. In most cases, a video platform with an embed is the lighter option. So before you raise any limit, ask yourself whether the file really needs to be that big.
What other options exist for very large files?
Some files, for instance, simply do not belong in a browser upload. A large database backup, a bulk set of product images or a theme package all fall into this group. For these, choosing another transfer method is healthier than pushing the limit very high.
- Transfer the file straight to the server with FTP or SFTP.
- Use the control panel's file manager, which sometimes runs with a higher limit.
- Restore database backups with command line tools.
- Split large media archives into parts before uploading.
If you do not know how to set up FTP, our guide on creating an FTP account in cPanel walks through the steps. For database files, our database backup and restore guide offers a safer route. These options keep you from growing the web upload limit for no good reason.
Can a CDN or security layer return a 413?
Yes, it can. If a CDN, reverse proxy or web application firewall sits in front of your site, that layer applies its own request size limit. If it rejects the request there, your server never sees it. So no matter how many settings you change on the server, the error persists.
These limits also vary by service and plan. Instead of quoting a number from memory, we suggest checking your provider's current documentation. The design of the error page and the response headers usually reveal which layer rejected the request.
Here is one test method: try the same upload while bypassing the CDN and going straight to the origin. You can do this through a temporary subdomain that points directly to the server. If the direct request works, the limit lives in the CDN layer. For other problems between a CDN and the origin, see our Cloudflare 522 guide.
How do timeout settings mix into upload problems?
After you raise the size limit, large files may then hit a timeout. Bigger files take longer to upload; on slow connections especially, that time can exceed how long the web server or PHP waits. In that case you see a different error, not a 413.
For example, when Nginx runs in front and PHP behind it, both sides have their own wait times. When one runs out, the connection drops. Therefore whenever you raise the size limit by a lot, review the timeout settings too. We do not quote exact values here, because the right duration depends on file size, connection speed and hosting plan.
A practical rule: if you can move large files via FTP or the file manager instead of a web form, you remove the timeout problem from the start. The web form then stays for everyday images and documents.
Why do APIs and form submissions return 413?
Also, a 413 is not limited to file uploads. When an app sends a very large JSON body to an API, the same code comes back. Apps that encode images as text and send them inside a form grow request sizes especially fast.
In this case the fix is usually to shrink the request, not raise the limit. For example, sending the image to a separate upload endpoint and passing only its link inside the JSON cuts request size sharply. Also, splitting bulk submissions into small batches lowers both the 413 risk and the chance of a timeout.
- Measure the request body size in your developer tools.
- Upload images separately instead of embedding them as text.
- Break bulk operations into pages or batches.
- Document the request sizes your API expects.
This approach removes the need to keep raising the server limit. That way you keep security intact and make your app more predictable.
What is the right step-by-step order for diagnosis and repair?
The fastest way to solve a 413 is to check the layers in order, from the outside in. This sequence prevents the classic time waster of changing everything at once.
- Note how the error page looks and the status code in the browser network tab.
- Find the exact size of the file you are trying to upload.
- If a CDN or security layer exists, test while bypassing it.
- On Nginx, check client_max_body_size.
- If you use Apache, search for LimitRequestBody lines.
- On the PHP side, read upload_max_filesize, post_max_size and memory_limit.
- Change only the layer that sets the limit, then test again.
- Write down the change and the reason for it.
The last step looks small but matters. Months later, after a server move or a PHP version change, the same error returns. With a note, you remember which setting changed and why within minutes. Also, change only one variable per step; when you change two settings at once, you never learn which one solved the problem.
How do you confirm the change worked?
Changing a setting does not mean the problem is solved. If you skip verification, the error comes back with the next big upload. So we recommend a short checklist after every change.
- Confirm in the panel or a PHP info page that the new values are actually active.
- Upload a file slightly below the limit and confirm it succeeds.
- Upload a file slightly above the limit and confirm you get the expected error.
- Repeat the test from another browser and, if possible, another network.
People often skip step three; still, it is very useful. Getting the expected error proves the limit works where you set it. Also, if you used a PHP info page, remove it as soon as the test ends, because leaving server details public creates a security risk.
A realistic example scenario: the catalog PDF won't upload
Here is an example scenario. A manufacturer wants to add its product catalog as a PDF. The WordPress media library shows a high upload limit, but during upload a page appears that says "413 Request Entity Too Large" with "nginx" underneath.
Specifically, the first clue is the "nginx" signature on the error page. The limit WordPress displays comes from PHP, so it misleads; the PHP limit is high, but the Nginx layer in front still runs close to its default. Therefore raising PHP values changes nothing.
To fix it, you raise client_max_body_size in the site's Nginx server block to a level that matches post_max_size in PHP. You test the config and reload Nginx. Then you try the file again. Compressing the PDF at the same time also helps visitors download it faster.
What are the most common 413 Request Entity Too Large mistakes?
These are the mistakes we see most often in the field with this error:
- Raising only upload_max_filesize and leaving post_max_size as it was.
- Working only on PHP settings while Nginx sits in front.
- Setting the limit to 0 and disabling the size check completely.
- Forgetting to reload the web server or PHP handler after the change.
- Giving the whole site a huge limit instead of widening only the path that needs it.
- Raising the limit again and again instead of shrinking images.
Above all, setting the limit to 0 is risky. According to the Nginx and Apache docs, that value turns off the size check. A malicious actor could then drain server resources by sending huge requests. So picking the smallest value that meets your need is always the safer choice.
How does raising the upload limit affect security and performance?
An upload limit works like a seat belt that protects your server from oversized requests. The higher you push it, the more bandwidth, disk and memory a single request can consume. On shared hosting, that can also slow down other processes on the same account.
That is why we suggest two principles. First, raise the limit only on paths that truly accept large files. Second, check file types and sizes in the app as well. Then, even with a generous web server limit, the app accepts only the files it expects.
On the performance side, remember that PHP caching and handler settings also play a role during uploads. Our OPcache guide helps you understand how PHP runs. And if you see connection errors after big uploads, our ERR CONNECTION REFUSED guide helps you check whether the web server stopped.
When should you get expert help?
If you have checked each layer and still cannot find the source, getting help makes sense. In setups where Nginx and Apache work together, a CDN sits in front, or several PHP versions run side by side, the layers can hide each other.
For example, raising a limit in one layer changes the error message and makes the problem look solved, while the request now stops at the next layer. Untangling such chains means measuring and noting every change. As Talha Aslan and team, we build sites where uploading content and images from the admin panel just works. A clean server configuration, optimized images and lean code are a natural part of our web design services.
How does the scope of our web design work relate to this problem?
Our web design work covers information architecture and UX, brand-specific design, lean code built for speed and Core Web Vitals, optimized images, proper caching and a clean server configuration. An admin panel where you edit text, images and contact details yourself is part of the scope too.
In practice, the process runs through discovery and scope, design approval, development, and launch with measurement in place. You see every page on a staging environment before launch, and we test upload flows at that stage. If you are planning a new site, our corporate website design page lays out the scope and the process in detail.



