Nginx 502 Gateway Error: connect() to unix:/home/user/project/project.sock failed

Nginx 502 Gateway Error: connect() to unix:/home/user/project/project.sock failed

我以前遇到过这个错误,但似乎无法弄清楚为什么会这样。

最终抛出 502 Bad Gateway 错误。

如果我执行 nginx -t,我得到:

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

我的语法出现在: /etc/nginx/sites-enabled 看起来不错。

这是 sites-enabled 中的站点:

server {
    listen 80;
    server_name <my-server-name-ip-here>;

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

    root /home/user/project/projenv;

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

}

获取错误:

connect() to unix:/home/user/project/project.sock failed

这是我的初始化脚本:

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/projenv/bin
chdir /home/user/project
exec gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi:app

知道我应该解决什么问题吗?? 谢谢!

我认为这可能是权限错误。检查套接字是否可被客户端和服务器读写。