pyramid+uwsgi+nginx, unix socket connection refused

1,695 views
Skip to first unread message

Chung WONG

unread,
Feb 26, 2014, 5:31:39 AM2/26/14
to pylons-...@googlegroups.com
Hi list,

There is a socket connection refused problem in nginx(uwsgi?) that I have no idea how to fix it.
I am not even sure if I am on the right track as I am following the instructions here
I hope someone can shed some light on it.
Here are the related files

nginx: 

website.conf
server {
    listen          80;
    access_log      off;
    error_log       /var/log/nginx/http.error.log;

    charset         utf-8;
    server_name     example.local;
    location / {
        uwsgi_pass  unix:///tmp/uwsgi.sock;
        include     uwsgi_params;
    }
}


development.ini

[uwsgi]
socket = /tmp/uwsgi.sock
chmod-socket = 777
chown-socket = www-data
gid = www-data
uid = www-data
master = true
processes = 4
harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
daemonize = ./uwsgi.log
pidfile = ./pid_5000.pid
listen = 256 
max-requests = 1000
reload-on-as = 128 
reload-on-rss = 96
no-orphans = true
log-slow = true
virtualenv = /home/chung/opt/Python-2.7.5/bin/env

uwsgi.log

*** Starting uWSGI 2.0.1 (64bit) on [Wed Feb 26 21:26:42 2014] ***
compiled with version: 4.8.2 on 24 February 2014 20:28:34
os: Linux-3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01)
nodename: debian
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/chung/opt/Python-2.7.5/bin/env/example
writing pidfile to ./pid_5000.pid
detected binary path: /home/chung/opt/Python-2.7.5/bin/env/bin/uwsgi
your processes number limit is 63212
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
Listen queue size is greater than the system max net.core.somaxconn (128).


uwsgi.sock

-rw-r--r-- 1 www-data www-data    0 Feb 26 21:19 uwsgi.sock

http.error.log

2014/02/26 21:28:33 [error] 6900#0: *8 connect() to unix:///tmp/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: example.local, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "example.local"
2014/02/26 21:28:33 [error] 6900#0: *8 connect() to unix:///tmp/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: example.local, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "example.local"

any help would be appreciated. Thanks

Roberto De Ioris

unread,
Feb 26, 2014, 5:37:26 AM2/26/14
to pylons-...@googlegroups.com

> Hi list,
>
> There is a socket connection refused problem in nginx(uwsgi?) that I have
> no idea how to fix it.
> I am not even sure if I am on the right track as I am following the
> instructions here <http://liangsun.org/posts/pyramid-nginx-uwsgi-mysql/>
> I hope someone can shed some light on it.
> Here are the related files
>
> nginx:
>
> website.conf
> *server {*
> * listen 80;*
> * access_log off;*
> * error_log /var/log/nginx/http.error.log;*
>
> * charset utf-8;*
> * server_name example.local;*
> * location / {*
> * uwsgi_pass unix:///tmp/uwsgi.sock;*
> * include uwsgi_params;*
> * }*
> *}*
>
>
> development.ini
>
> *[uwsgi]*
> *socket = /tmp/uwsgi.sock*
> *chmod-socket = 777*
> *chown-socket = www-data*
> *gid = www-data*
> *uid = www-data*
> *master = true*
> *processes = 4*
> *harakiri = 60*
> *harakiri-verbose = true*
> *limit-post = 65536*
> *post-buffering = 8192*
> *daemonize = ./uwsgi.log*
> *pidfile = ./pid_5000.pid*
> *listen = 256 *
> *max-requests = 1000*
> *reload-on-as = 128 *
> *reload-on-rss = 96*
> *no-orphans = true*
> *log-slow = true*
> *virtualenv = /home/chung/opt/Python-2.7.5/bin/env*
>
> uwsgi.log
>
> **** Starting uWSGI 2.0.1 (64bit) on [Wed Feb 26 21:26:42 2014] ****
> *compiled with version: 4.8.2 on 24 February 2014 20:28:34*
> *os: Linux-3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01)*
> *nodename: debian*
> *machine: x86_64*
> *clock source: unix*
> *pcre jit disabled*
> *detected number of CPU cores: 4*
> *current working directory: /home/chung/opt/Python-2.7.5/bin/env/example*
> *writing pidfile to ./pid_5000.pid*
> *detected binary path: /home/chung/opt/Python-2.7.5/bin/env/bin/uwsgi*
> *your processes number limit is 63212*
> *your memory page size is 4096 bytes*
> *detected max file descriptor number: 1024*
> *lock engine: pthread robust mutexes*
> *thunder lock: disabled (you can enable it with --thunder-lock)*
> *Listen queue size is greater than the system max net.core.somaxconn
> (128).*


Here your uWSGI process died, so it is normal nginx cannot connect to it


--
Roberto De Ioris
http://unbit.it

Chung WONG

unread,
Feb 26, 2014, 6:11:38 AM2/26/14
to pylons-...@googlegroups.com
thanks Roberto, I removed the listen param in the .ini and that particular error has gone.
However, there are another two errors which I think they are related to Paste.

*** Starting uWSGI 2.0.1 (64bit) on [Wed Feb 26 22:02:36 2014] ***
compiled with version: 4.8.2 on 24 February 2014 20:28:34
os: Linux-3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01)
nodename: debian
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/chung/opt/Python-2.7.5/bin/env/example
writing pidfile to ./pid_5000.pid
detected binary path: /home/chung/opt/Python-2.7.5/bin/env/bin/uwsgi
your processes number limit is 63212
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
Python version: 2.7.5 (default, Jun 17 2013, 01:43:20)  [GCC 4.7.2]
Set PythonHome to /home/chung/opt/Python-2.7.5/bin/env
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xb938f0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 404760 bytes (395 KB) for 4 cores
*** Operational MODE: preforking ***
Loading paste environment: config:/home/chung/opt/Python-2.7.5/bin/env/example/development.ini
ImportError: No module named script.util.logging_config
ImportError: No module named deploy

When I run 
../bin/uwsgi --ini-paste-logged development.ini
It produce the above error, while if i run without the log
../bin/uwsgi --ini-paste development.ini
This error ImportError: No module named script.util.logging_config went away, while the remaining one is still there.

I've checked my virtualenv does have paste.deploy as I can import paste.deploy but I couldn't find paste.script.util.logging_config

Did I miss some paste extra modules?

Thanks again 



Chung WONG

unread,
Feb 26, 2014, 7:16:12 AM2/26/14
to pylons-...@googlegroups.com
For some reason, after upgraded PasteDeploy from 1.5.0 to 1.5.2, both errors have gone.

Problem Solved!

Thanks

Zagloj

unread,
Feb 26, 2014, 7:02:01 AM2/26/14
to pylons-...@googlegroups.com
Hi, in your ini file you could try with ip:port in socket and listen to
that port from nginx, for example:
socket = 127.0.0.1:3031

Apart you could define home and config like this:
home = path_to_your_env
paste =
config:path_to_your_ini_file.ini

Hope this helps.

El Wed, 26 Feb 2014 02:31:39 -0800 (PST) Chung WONG <wch...@gmail.com>
escribió:
> Hi list,
>
> There is a socket connection refused problem in nginx(uwsgi?) that I
> have no idea how to fix it.
> I am not even sure if I am on the right track as I am following the
> instructions here
> <http://liangsun.org/posts/pyramid-nginx-uwsgi-mysql/> I hope someone
> can shed some light on it. Here are the related files
>
> nginx:
>
> website.conf
> *thunder lock: disabled (you can enable it with --thunder-lock)*
> *Listen queue size is greater than the system max net.core.somaxconn
> (128).*
>
>
> uwsgi.sock
>
> *-rw-r--r-- 1 www-data www-data 0 Feb 26 21:19 uwsgi.sock*
>
> http.error.log
>
> *2014/02/26 21:28:33 [error] 6900#0: *8 connect() to
> unix:///tmp/uwsgi.sock failed (111: Connection refused) while
> connecting to upstream, client: 127.0.0.1, server: example.local,
> request: "GET / HTTP/1.1", upstream:
> "uwsgi://unix:///tmp/uwsgi.sock:", host: "example.local"* *2014/02/26
> 21:28:33 [error] 6900#0: *8 connect() to unix:///tmp/uwsgi.sock
> failed (111: Connection refused) while connecting to upstream,
> client: 127.0.0.1, server: example.local, request: "GET /favicon.ico
> HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host:
> "example.local"*
Reply all
Reply to author
Forward
0 new messages