Python 3, nginx, uwsgi, debian, connection refused.

37 views
Skip to first unread message

blax...@yahoo.com

unread,
Oct 25, 2018, 9:36:27 AM10/25/18
to Kotti
Following below installation document:

after restarting nginx, noticed the socks file was not created and got file not found error in nginx log files,
so manually created the file in /tmp and chmod 666 as it set in wsgi section of kotti.ini.


now I get below error:
2018/10/25 08:26:05 [error] 24834#24834: *3 connect() to unix:/tmp/domainname.sock failed (111: Connection refused) while connecting to upstream, client: X.X.X.X, server: domainname.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/tmp/domainname.sock:", host: "domainname.com"

supervisor process is pointed to kotti.ini but there is no directive in nginx config to point to kotti.ini
so I think there are some steps are missing in document.


Thanks for help

Andreas Kaiser

unread,
Oct 25, 2018, 10:09:56 AM10/25/18
to blaxxton via Kotti

On 25 Oct 2018, at 15:36, blaxxton via Kotti wrote:

Following below installation document:
https://kotti.readthedocs.io/en/latest/developing/basic/deployment.html

after restarting nginx, noticed the socks file was not created and got file
not found error in nginx log files,
so manually created the file in /tmp and chmod 666 as it set in wsgi
section of kotti.ini.

You shouldn't do that. If the file is not created where you expect it, you either have specified a wrong path or the user running uwsgi doesn't have the permission required to create that file.

now I get below error:
2018/10/25 08:26:05 [error] 24834#24834: *3 connect() to
unix:/tmp/domainname.sock failed (111: Connection refused) while connecting
to upstream, client: X.X.X.X, server: domainname.com, request: "GET /
HTTP/1.1", upstream: "uwsgi://unix:/tmp/domainname.sock:", host:
"domainname.com"

supervisor process is pointed to kotti.ini but there is no directive in
nginx config to point to kotti.ini
so I think there are some steps are missing in document.

nginx doesn't need kotti.ini at all. You just have to make sure, that the path

uwsgi_pass unix:/tmp/domainname.sock;

in your nginx config matches the path in your kotti.ini:

[uwsgi]
socket = /tmp/domainname.sock

If you doublechecked the above and still get the same error, check owner/group and permissions for the socket to allow both the user running nginx and the user running uwsgi can read and write to the socket file.

HTH,
Andreas

Blaxton

unread,
Oct 25, 2018, 11:47:59 AM10/25/18
to blaxxton via Kotti
/tmp is writable by everyone, so the nginx user/process should be able to write
regardless of permission or ownership.

ls -lad /tmp
drwxrwxrwt 7 root root 4096 Oct 25 10:40 /tmp



to make sure wsgi is using the same user and permission added below lines
to kotti.ini


chown-socket=www-data:www-data
chmod-socket = 664
uid = www-data
gid = www-data

considering nginx is running under www-data process:
www-data 25998 25997  0 10:35 ?        00:00:00 nginx: worker process




--
You received this message because you are subscribed to the Google Groups "Kotti" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kotti+un...@googlegroups.com.
To post to this group, send email to ko...@googlegroups.com.
Visit this group at https://groups.google.com/group/kotti.
To view this discussion on the web visit https://groups.google.com/d/msgid/kotti/774F7A01-C543-45E5-A9E8-A2619AE21BD9%40binary-punks.com.

For more options, visit https://groups.google.com/d/optout.

Blaxton

unread,
Oct 25, 2018, 6:28:16 PM10/25/18
to blaxxton via Kotti
Following below document:


I am able to connect to nginx socket and browse on port 80:
server {
    listen 80;
    server_name domainname.com;
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
    }
}

using command:
uwsgi --socket 127.0.0.1:3031 --wsgi-file foobar.py --master --processes 4 --threads 2

therefore nginx config is ok, it only left wsgi config in kotti.ini

There should be a wsgi file, to:

There should be the same file for kotti.

I have already setup wsgi and Apache to use Pyramid using below wsgi config file:
from pyramid.paster import get_app, setup_logging

ini_path = '/path/to/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')



There has to be the same config for kotti but nothing has mentioned.


Andreas Kaiser

unread,
Oct 26, 2018, 3:39:41 AM10/26/18
to 'Blaxton' via Kotti

On 26 Oct 2018, at 0:24, 'Blaxton' via Kotti wrote:

Following below document:https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html

I am able to connect to nginx socket and browse on port 80:server {
    listen 80;
    server_name domainname.com;
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
    }
}

using command:
uwsgi --socket 127.0.0.1:3031 --wsgi-file foobar.py --master --processes 4 --threads 2
therefore nginx config is ok, it only left wsgi config in kotti.ini
There should be a wsgi file, to:
https://github.com/FriendCode/python-django-sample/blob/master/hellodjango/wsgi.py


There should be the same file for kotti.
I have already setup wsgi and Apache to use Pyramid using below wsgi config file:from pyramid.paster import get_app, setup_logging

ini_path = '/path/to/development.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')

There has to be the same config for kotti but nothing has mentioned.

No, uWSGI doesn't need a wsgi-file. It can load the application from the ini file. This is from a Kotti application's ini file I'm running:

[app:tng3]
use = egg:kotti
…

[filter:fanstatic]
use = egg:fanstatic#fanstatic
…

[pipeline:main]
pipeline =
    fanstatic
    tng3

[uwsgi]
virtualenv = /usr/local/app
paste = config:/usr/local/app/app.ini
limit-post = 2097152
post-buffering = 2097152
processes = 2
threads = 2
enable-threads = true
env = LANG=en_US.UTF-8

uWSGI is run like this:

/usr/local/bin/uwsgi-2.7 --ini /usr/local/app/app.ini --master --uid uwsgi --gid www --pidfile /var/run/uwsgi.pid -d /var/log/uwsgi.log -s /tmp/app.socket --chmod-socket=660 --chown-socket=uwsgi:www -L

You can freely move uWSGI configuration options from command line options to the [uwsgi] section in your ini file or vice versa.

Reading over the thread and docs again, I think the documentation is missing the paste = config:/usr/local/app/app.ini line in the the ini file.

HTH,
Andreas

Blaxton

unread,
Nov 14, 2018, 9:09:29 AM11/14/18
to 'Blaxton' via Kotti
Checking supervisor log file noticed there is no uwsgi_python in path:
2018-10-26 15:15:52,283 INFO spawnerr: can't find command 'uwsgi_python'
2018-10-26 15:15:53,284 INFO spawnerr: can't find command 'uwsgi_python'
2018-10-26 15:15:55,287 INFO spawnerr: can't find command 'uwsgi_python'
2018-10-26 15:15:58,291 INFO spawnerr: can't find command 'uwsgi_python'
2018-10-26 15:15:58,291 INFO gave up: kotti entered FATAL state, too many start retries too quickly


Document says:

Create a supervisor config for Kotti / uWSGI in /etc/supervisor/conf.d/kotti.conf:

[program:kotti]
autorestart=true
command=uwsgi_python --ini-paste /home/kotti/kotti.ini
directory=/home/kotti
redirect_stderr=true

what package contain uwsgi_python ?

Thanks

--
You received this message because you are subscribed to the Google Groups "Kotti" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kotti+un...@googlegroups.com.
To post to this group, send email to ko...@googlegroups.com.
Visit this group at https://groups.google.com/group/kotti.

Blaxton

unread,
Nov 14, 2018, 10:48:03 AM11/14/18
to 'Blaxton' via Kotti
Sorry guys, first time using nginx and uwsgi.

changed uwsgi_python to /home/kotti/bin/uwsgi
and added logto directive to check uwsgi errors:
logto = /var/log/uwsgi/uwsgi.log

checking the uwsgi log file getting postgres access denied
but now I know where I stand, thanks for all your help,
will send update once figured the rest.

quick question, how may I contribute to kotti documentation ?
do I need to know about sphinx to edit the kotti documentation ?


Andreas Kaiser

unread,
Nov 14, 2018, 2:17:52 PM11/14/18
to 'Blaxton' via Kotti

On 14 Nov 2018, at 16:48, 'Blaxton' via Kotti wrote:

Sorry guys, first time using nginx and uwsgi.
changed uwsgi_python to /home/kotti/bin/uwsgi
and added logto directive to check uwsgi errors:
logto = /var/log/uwsgi/uwsgi.log

checking the uwsgi log file getting postgres access denied

This is usually related to the contents of your pg_hba.conf.

but now I know where I stand, thanks for all your help,will send update once figured the rest.


quick question, how may I contribute to kotti documentation?

The docs reside in the docs directory of the Kotti repo. You'd usually fork Kotti on Github, make some changes to your fork (probably in a branch) and create a pull request.

do I need to know about sphinx to edit the kotti documentation ?

Unless you want to change the docs structure or create new pages, you don't need to know anything (or at most very little) about Sphinx. The "pages" are simple reStructuredText documents. However, you could have Sphinx render the HTML locally to check if your changes look like intended:

cd <your kotti checkout directory>
python setup.py docs
cd docs
make html

HTH,
Andreas

Blaxton

unread,
Nov 17, 2018, 10:41:45 AM11/17/18
to 'Blaxton' via Kotti
Thank you Andreas,

I have finally installed Kotti using nginx, uwsgi and Python 3 on Debian 9.

Thanks for all your help.


--
You received this message because you are subscribed to the Google Groups "Kotti" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kotti+un...@googlegroups.com.
To post to this group, send email to ko...@googlegroups.com.
Visit this group at https://groups.google.com/group/kotti.
Reply all
Reply to author
Forward
0 new messages