连接到上游时,Nginx / Gunicorn connect()到.sock失败(111:连接被拒绝)时出错

时间:2015-12-13 14:49:24

标签: python ubuntu nginx

我已经做了无休止的搜索并尝试解决这个问题,但这无效。

我正在使用Python 3.3/Gunicorn/Nginx,当我尝试运行我的网站时,我得到了:

[error] 904#0: *1 connect() to unix:/home/user/project/project.sock failed (111: Connection refused) while connecting to upstream, client: , server: mysite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/user/project/project.sock:/favicon.ico", host: "mysite.com", referrer: "mysite.com/"

我完全关注this article,经过多次尝试重新尝试,我仍然收到此错误。

这是我的配置的样子: /etc/init

中的暴发户脚本
description "Gunicorn application server running myproject"

    start on runlevel [2345]
    stop on runlevel [!2345]

    respawn          #respawn this on reboot
    setuid user        #set as unix user 'jd' to run as
    setgid www-data  #user used by nginx

    env PATH=/home/user/project/projectenv/bin
    chdir /home/user/project
    exec gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi

此文件的权限:

    chmod 644
    user user 373 Dec 13 09:21 homepage.conf

** nginx

config**
    server {
        listen 80;

        server_name mysite.com;

        error_log /home/user/project/nginx_error.log info;

        root /home/user/project/projectenv;

        location / {
            include proxy_params;
            proxy_pass http://unix:/home/user/project/project.sock;
        }

    }

如果我在nginx配置的目录中运行nginx -t,它会显示:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 

/home/user/project/project.sock;

的权限
srwxrwx--- 1 user www-data 

我的wsgi.py文件(如文章所述)包含:

from homepage import application

if __name__ == "__main__":
    application.run()

有趣的是,如果我尝试这个命令:

gunicorn --bind 0.0.0.0:8000 wsgi

概述了here

Gunicorn启动很好,我可以完美地查看我的页面。

真正的问题是,导致此问题无法从ubuntu startup script中的/etc/init运行的问题是什么? ...因为脚本正在运行fin

有人看到了吗?

谢谢。

0 个答案:

没有答案