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

  • Posted September 6, 2014


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 ?


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

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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 ;)