Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I originally posted this on Stack Overflow, then remembered that SO isn't for server-based questions.

Hey guys,

When I try to upload a file to my site, I'm getting the Nginx "413 Request Entity Too Large" error, however in my nginx.conf file I've already explicitly stated the max size to be about 250MB at the moment, and changed the max file size in php.ini as well (and yes, I restarted the processes). The error log gives me this:

2010/12/06 04:15:06 [error] 20124#0: *11975 client intended to send too large body: 1144149 bytes, client:, server:, request: "POST /upload HTTP/1.1", host: "", referrer: ""

As far as I know, 1144149 bytes isn't 250MB... Is there something I'm missing here?

Here's the base Nginx config:

user  nginx;
worker_processes  8;
worker_rlimit_nofile 100000;

error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/;

events {
    worker_connections  1024;
    use epoll;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    client_max_body_size 300M;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    gzip            on;
    gzip_static     on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    keepalive_timeout  300;
    limit_zone   myzone  $binary_remote_addr  10m;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/sites/*;

And the vhost for the site:

server {
 listen  80;

 access_log /var/log/nginx/;

 location / {
  index index.html index.htm index.php;
  root /var/www/;

  if (!-e $request_filename) {
   rewrite ^/([a-z,0-9]+)$ /$1.php last;
   rewrite ^/file/(.*)$ /file.php?file=$1;

  location ~ /engine/.*\.php$ {
   return 404;

  location ~ ^/([a-z,0-9]+)\.php$ {
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include  fastcgi_params;

Am I missing something here?

share|improve this question
Did you find a solution? – danorton Sep 5 '11 at 17:27

Try moving client_max_body_size to inside the server block.

share|improve this answer
Sorry I took so long to get back to you. I tried that originally, and it didn't seem to work either. – Elliot Dec 6 '10 at 23:58

You might be setting client_max_body_size in multiple locations or files. For example, the last line of your config includes any config files from the sites directory: include /etc/nginx/sites/*

Find all occurrences of client_max_body_size by running this command in your nginx directory:

sudo grep -R 'client_max_body_size' ./*

If you remove or update all those occurrences, you should be in good shape. I had the same issue and was racking my mind as to what it could be.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.