N
N
nazandr2016-10-03 15:20:24
Django
nazandr, 2016-10-03 15:20:24

How to fix 502 Bad Gateway nginx/1.10.0 (Ubuntu) Nginx error?

How to fix a mistake

2016/10/03 11:58:14 [error] 22667#22667: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 90.154.72.246, server: 95.85.3.58, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "95.85.3.58:8000"
2016/10/03 12:03:22 [error] 22667#22667: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 90.154.72.246, server: 95.85.3.58, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "95.85.3.58:8000"
2016/10/03 12:06:38 [notice] 22806#22806: signal process started
2016/10/03 12:06:43 [error] 22810#22810: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 90.154.72.246, server: 95.85.3.58, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "95.85.3.58:8000"
2016/10/03 12:08:20 [error] 22810#22810: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 90.154.72.246, server: 95.85.3.58, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "95.85.3.58:8000"

nginx.conf
# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name 95.85.3.58; # substitute your machine's IP address or FQDN
    charset     utf-8;

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

    location /static {
        alias /ProjectBlog/blog/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /ProjectBlog/blog/uwsgi_params; # the uwsgi_params file you installed
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Innokentiev, 2016-10-03
@artinnok

I think you have uwsgi listening on a different port - try this:

uwsgi --http :8001
либо
uwsgi --socket :8001

Also, you have nginx on a different port - you need to set it to 80:
Also, read this article.
Usually the work is structured like this:
Nginx (80) -> uWSGI (8000)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question