UWSGI nginx: connect () error failed (111: connection refused) when connecting to the upstream

I am experiencing 502 gateway errors when accessing my IP on nginx ( http: //52.xx.xx.xx/ ), the logs just say this:

2015/09/18 13:03:37 [error] 32636 # 0: * 1 connect () error (111: connection rejected) when connecting to the upstream channel, client: xx.xx.xx.xx, server: xx.xx . xx.xx, request: "GET / HTTP / 1.1", upstream: "uwsgi: //127.0.0.1: 8000", host: "xx.xx.xx.xx"

my nginx.conf file

# 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:8000; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 80; # the domain name it will serve for server_name xx.xx.xx.xx; # substitute your machine IP address or FQDN charset utf-8; access_log /home/ubuntu/test_django/nginx_access.log; error_log /home/ubuntu/test_django/nginx_error.log; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias /home/ubuntu/test_django/static/media/; # your Django project media files - amend as required } location /static { alias /home/ubuntu/test_django/static/; # your Django project static files - amend as required } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /home/ubuntu/test_django/uwsgi_params; # the uwsgi_params file you installed } } 

Something is wrong with the nginx.conf file ..... if I use conf by default, then it works.

+6
source share
5 answers

I solved this by changing the socket configuration in uwsgi.ini from socket = 127.0.0.1:3031 to socket = :3031 . I ran into this problem when running nginx in one Docker container and uWSGI in another. If you use the command line to start uWSGI, run uwsgi --socket :3031 .

Hope this helps someone facing the same issue while deploying a Django application using Docker.

+3
source

change this address:

 include /home/ubuntu/test_django/uwsgi_params; 

to

 include /etc/nginx/uwsgi_params; 
0
source

I ran into this problem when setting up env on nginx + gunicorn and resolved it by adding '*' to ALLOWED_HOSTS or your specific domain.

-1
source

In my case, it worked with the debian server:

 include /etc/nginx/uwsgi_params; 

In the location tag in my nginx server configuration file, for example:

 location /sistema { include /etc/nginx/uwsgi_params; uwsgi_pass unix://path/sistema.sock; } 

Also, check if the following packages are installed: uwsgi-plugin-Python

-1
source

pip3 install uWSGI did pip3 install uWSGI thing for me: D

-1
source

All Articles