【问题标题】:Django + uwsgi + nginx + CentOS 7 : connection refused on 8001 portDjango + uwsgi + nginx + CentOS 7:8001 端口上的连接被拒绝
【发布时间】:2015-06-14 20:06:40
【问题描述】:

Django + uwsgi + nginx + CentOS 7:8001 端口连接被拒绝

当我尝试访问 http://domain.com:8000 时收到 http 520 错误

nginx.conf

    upstream django {
        # connect to this socket
        # server unix:///tmp/uwsgi.sock;    # for a file socket
        server 127.0.0.1:8001;      # for a web port socket

        }

    server {
        # the port your site will be served on
        listen      8000;
        # the domain name it will serve for
        server_name domain.com;   # substitute your machine's IP address or FQDN
        #root /home/mysite;
        charset     utf-8;

        #Max upload size
        client_max_body_size 75M;   # adjust to taste


        # Finally, send all non-media requests to the Django server.
        location / {
            uwsgi_pass  django;
            include     /home/mysite/uwsgi_params; # or the uwsgi_params you installed manually
            }


        }

/var/log/nginx/error.log 上的错误消息

2015/04/09 12:28:07 [error] 23235#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 118.131.206.235, server: domain.com, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "domain.com:8000"
2015/04/09 12:28:08 [error] 23235#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 118.131.206.235, server: domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "domain.com:8000"

我已经尝试了所有方法,但找不到任何线索表明它给了我 http 502 错误。

【问题讨论】:

  • 你的uWSGI服务器真的在运行吗?是否绑定到 8001 端口?

标签: python linux django nginx uwsgi


【解决方案1】:

默认情况下,SELinux 可能会阻止此类连接。

您需要检查日志文件 /var/log/audit/audit.log 以确定它。

或者使用以下命令暂时停止 SELinux:

setenforce 0

【讨论】:

  • 我已经禁用了 SELinux,并且没有 audio.log 文件。 :(
猜你喜欢
  • 2015-04-30
  • 2020-02-08
  • 2017-11-24
  • 2021-04-04
  • 2016-05-25
  • 2017-07-23
  • 2020-04-29
  • 1970-01-01
  • 2018-11-26
相关资源
最近更新 更多