Error: "invalid number of arguments in "uwsgi_param" directive" on nginx restart

Vadim Tikanov asked:

CentOS 6.6, nginx 1.0.15.

I’m trying to configure nginx <-> uwsgi <-> Django stack, using this tutorial. The nginx conf file is:

upstream django {

server {
    listen      8000;
    server_name; # an IP address of my server here
    charset     utf-8;
    client_max_body_size 75M;

    location /media  {
        alias /projects/myproject/media;

    location /static {
        alias /projects/myproject/static;

    location / {
        uwsgi_pass  django;
        include     /projects/myproject/uwsgi_params;

The uwsgi_params file is:

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

And on trying to start nginx I get the error:

$ sudo service nginx restart
nginx: [emerg] invalid number of arguments in "uwsgi_param" directive in /projects/myproject/uwsgi_params:12
nginx: configuration file /etc/nginx/nginx.conf test failed

Looks like nginx is confused with line 12 of uwsgi_params file, which is (given the 1st line is blank) an HTTPS config.

How do I fix that?

My answer:

nginx is complaining about this line:

uwsgi_param  HTTPS              $https if_not_empty;

The if_not_empty parameter was added in nginx 1.1.11, so your version of nginx is too old to use it.

Since you are on CentOS, you should run the latest stable nginx provided by’s own CentOS repository. Updating to the latest stable nginx via this method will resolve the problem.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.