Could not run nginx with gunicorn, getting permission denied error while connecting to upstream.

September 6, 2014 9k views


I have hosted django with nginx and gunicorn.

I am getting following error.

# 1 connect() to failed (13: Permission denied) while connecting to upstream, client:, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "", host: "<domainname>

[Same configuration is working on my local centos machine]

Digital ocean vps details:

Machine: centos-7
User: ftpuser1

I am running nginx using user "ftpuser1"

owner of /var/cache/nginx is "ftpuser1" with 777 permissions recursively

owner of source code path is also "ftpuser1" with 777 permissions recursively

here is my /etc/nginx/conf.d/default.config config file content:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /home/ftpuser1/donation/templates;
        index  home.html;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

    # proxy the PHP scripts to Apache listening on
    #location ~ \.php$ {
    #    proxy_pass;

    # pass the PHP scripts to FastCGI server listening on
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #location ~ /\.ht {
    #    deny  all;

Can anyone help me in this ?

1 comment
  • What user are you running gunicorn as? Is SELinux enabled? Look in /var/log/audit/audit.log for any mentions of Nginx.

1 Answer

Hi, I faced the same problem the last two days, here are the steps I followed to solve it. Now I have mi server up and running again ;)

Have another answer? Share your knowledge.