(111: Connection refused) while connecting to upstream NGINX Uwsgi

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

(111: Connection refused) while connecting to upstream NGINX Uwsgi

ayman
after struggling for almost a week on this I feel I need to reach out for
assistance . Please Help

I am trying to deploy my project to a production environment


In terms of permissions I have read all the forums changed all permissions
i.e. 777 etc etc
srwxrwxrwx  uwsgi.sock  (owned by me full access ) !!
I've checked over and over all the directory structures etc. Ive swtiched
from unix sockets to http but still
no joy .

exact error


2017/09/18 06:32:56 [error] 15451#0: *1 connect() to
unix:////home/workspace/project//
tmp/uwsgi.sock failed (111: Connection refused) while connecting to
upstream, client: 1933
.247.239.160, server: website.xyz, request: "GET / HTTP/1.0", upstream:
"uwsgi://unix:////
/home/workspace/project/tmp/uwsgi.sock:", host: "www.website.xyz"


Nginx configuration:

upstream _django {
    server unix:////home/workspace/project/tmp/uwsgi.sock;
}

server {
   listen 62032;
   server_name website.xyz www.website.xyz ;

   location = /favicon.ico { access_log off; log_not_found off; }
   location = /test-this { return 200 "Yes, this is correct\n"; }
   location /foo { return 200 "YIKES  what a load of codswollop";}
   root  /home/workspace/project;

   location /static {
      alias   /home/workspace/project/testsite/assets;
    }

   location /assets {
      root   /home/workspace/project/testsite/assets;
    }

    location / {
        include /home/workspace/project/uwsgi_params;
        #include uwsgi parameters.
        uwsgi_pass _django;
        #tell nginx to communicate with uwsgi though unix socket
/run/uwsgi/sock.
    }




uwsgi ini file

# project.ini file
[uwsgi]
chdir =  /home/workspace/project/testsite
module=testsite.wsgi:application
socket  = /home/workspace/project/uwsgi.sock
chmod-socket    = 666
daemonize = /home/workspace/project/tmp/uwsgi.log
protocol = http
master = true
vacuum=true
max-requests=5000
processes = 10


start script

#! /bin/bash
PIDFILE=/home/workspace/project/startselvacura.pid

source /home/workspace/project/venv/bin/activate
uwsgi --ini /home/workspace/project/uwsgi-prod.ini --venv
/home/workspace/project/venv  --pidfile $PIDFILE
~                            



running https://www.asandhu.xyz/foo

does return the  expected result :

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,276427,276427#msg-276427

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: (111: Connection refused) while connecting to upstream NGINX Uwsgi

Anoop Alias
What is the output of 

ls -l /home/workspace/project/tmp/uwsgi.sock

and 

ps aux|grep nginx



On Mon, Sep 18, 2017 at 12:13 PM, sandyman <[hidden email]> wrote:
after struggling for almost a week on this I feel I need to reach out for
assistance . Please Help

I am trying to deploy my project to a production environment


In terms of permissions I have read all the forums changed all permissions
i.e. 777 etc etc
srwxrwxrwx  uwsgi.sock  (owned by me full access ) !!
I've checked over and over all the directory structures etc. Ive swtiched
from unix sockets to http but still
no joy .

exact error


2017/09/18 06:32:56 [error] 15451#0: *1 connect() to
unix:////home/workspace/project//
tmp/uwsgi.sock failed (111: Connection refused) while connecting to
upstream, client: 1933
.247.239.160, server: website.xyz, request: "GET / HTTP/1.0", upstream:
"uwsgi://unix:////
/home/workspace/project/tmp/uwsgi.sock:", host: "www.website.xyz"


Nginx configuration:

upstream _django {
    server unix:////home/workspace/project/tmp/uwsgi.sock;
}

server {
   listen 62032;
   server_name website.xyz www.website.xyz ;

   location = /favicon.ico { access_log off; log_not_found off; }
   location = /test-this { return 200 "Yes, this is correct\n"; }
   location /foo { return 200 "YIKES  what a load of codswollop";}
   root  /home/workspace/project;

   location /static {
      alias   /home/workspace/project/testsite/assets;
    }

   location /assets {
      root   /home/workspace/project/testsite/assets;
    }

    location / {
        include /home/workspace/project/uwsgi_params;
        #include uwsgi parameters.
        uwsgi_pass _django;
        #tell nginx to communicate with uwsgi though unix socket
/run/uwsgi/sock.
    }




uwsgi ini file

# project.ini file
[uwsgi]
chdir =  /home/workspace/project/testsite
module=testsite.wsgi:application
socket  = /home/workspace/project/uwsgi.sock
chmod-socket    = 666
daemonize = /home/workspace/project/tmp/uwsgi.log
protocol = http
master = true
vacuum=true
max-requests=5000
processes = 10


start script

#! /bin/bash
PIDFILE=/home/workspace/project/startselvacura.pid

source /home/workspace/project/venv/bin/activate
uwsgi --ini /home/workspace/project/uwsgi-prod.ini --venv
/home/workspace/project/venv  --pidfile $PIDFILE
~



running https://www.asandhu.xyz/foo

does return the  expected result :

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,276427,276427#msg-276427

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx



--
Anoop P Alias 


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: (111: Connection refused) while connecting to upstream NGINX Uwsgi

Francis Daly
In reply to this post by ayman
On Mon, Sep 18, 2017 at 02:43:37AM -0400, sandyman wrote:

Hi there,

> I am trying to deploy my project to a production environment

It looks like you have been trying lots of different things, and changing
some things each time.

It will probably be simpler for you if you find one tutorial on how to
use nginx to front django, and follow exactly that one. Do not try to
mix pieces from two or more until you understand what every config line
means; otherwise you will probably become confused.

> In terms of permissions I have read all the forums changed all permissions
> i.e. 777 etc etc
> srwxrwxrwx  uwsgi.sock  (owned by me full access ) !!
> I've checked over and over all the directory structures etc. Ive swtiched
> from unix sockets to http but still
> no joy .

First: decide do you want django to present itself on a unix socket,
or on a tcp port.

Next: decide do you want django to present itself as a uwsgi service,
or as a http service.

Then: configure django as the server, and configure nginx as the client
talking to that server.

> 2017/09/18 06:32:56 [error] 15451#0: *1 connect() to
> unix:////home/workspace/project//
> tmp/uwsgi.sock failed (111: Connection refused) while connecting to

There are lots of / characters there; they probably are not all needed.

> upstream, client: 1933
> .247.239.160, server: website.xyz, request: "GET / HTTP/1.0", upstream:
> "uwsgi://unix:////
> /home/workspace/project/tmp/uwsgi.sock:", host: "www.website.xyz"

That says that nginx thinks that django is presented as a uwsgi service,
on the unix socket /home/workspace/project/tmp/uwsgi.sock.

> [uwsgi]
> socket  = /home/workspace/project/uwsgi.sock
> protocol = http

That seems to say that django thinks that django presents itself as a
http service, on the unix socket /home/workspace/project/uwsgi.sock.

The two socket names are different. The two protocols are different. The
client is unlikely to successfully talk to the server, under those
conditions.

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx