Nginx connection refused error 111, bad gateway
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Please do not hurry to close it as duplicate. I searched through the web and still cannot find the way to make it work.
This is my working directory:
/var/www/flaskapp
- myproject.ini
- myproject.py
- myproject.sock
pycache- venv
- wsgi.py
myproject.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
wsgi.py
from myproject import app
if __name__ == "__main__":
app.run()
myproject.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
#location of log files
logto = /var/log/uwsgi/%n.log
I also created a systemd Unit file
/etc/systemd/system/myproject.service
[Unit]
Description=uWSGI instance serve myproject
After=network.target
[Service]
User = john
Group = www-data
WorkingDirectory=/var/www/flaskapp/
Environment="PATH=/var/www/flaskapp/venv/bin"
ExecStart=/var/www/flaskapp/venv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
and then
sudo systemctl start myproject
sudo systemctl enable myproject
Than configuration of nginx. nginx.conf I left unchanged but made corrections to /etc/nginx/sites-availible/myproject
server
listen 83;
server_name my_external_ip;
location /
include uwsgi_params;
uwsgi_pass unix:/var/www/flaskapp/flaskapp;
and made also a link to /etc/nginx/sites-enabled by command
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
After that: sudo systemctl restart nginx and sudo ufw allow 'Nginx Full'.
Now when I enter http://my_ip_address:83/ I see default nginx greeting and nothing else! Altough I think it should be my Hello There! made by my python-script. Don't know why...
Here is my logs:
/var/log/nginx/error.log
2018/02/08 22:17:51 [error] 2394#2394: *1 connect() to unix:/var/www/flaskapp/venv failed (111: Connection refused) while connecting to upstream, client: 46.146.0.30, server: 92.240.202.184, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/www/flaskapp/venv:", host: "my_external_ip:83"
And log of uwsgi:
current working directory: /var/www/flaskapp
detected binary path: /var/www/flaskapp/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 7157
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 myproject.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xf07550
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436560 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xf07550 pid: 2320 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2320)
spawned uWSGI worker 1 (pid: 2703, cores: 1)
spawned uWSGI worker 2 (pid: 2704, cores: 1)
spawned uWSGI worker 3 (pid: 2705, cores: 1)
spawned uWSGI worker 4 (pid: 2706, cores: 1)
spawned uWSGI worker 5 (pid: 2707, cores: 1)
Somewhere has been said that I need to reinstall uwsgi and also install pcre, but after doing this still no success, I really tried and searched all solutions related to this but with all effort I am getting nothing..
Please help me to detect problem and then to handle it...
Any help will be appreciated!
Thanks in advance!
nginx uwsgi
add a comment |Â
up vote
0
down vote
favorite
Please do not hurry to close it as duplicate. I searched through the web and still cannot find the way to make it work.
This is my working directory:
/var/www/flaskapp
- myproject.ini
- myproject.py
- myproject.sock
pycache- venv
- wsgi.py
myproject.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
wsgi.py
from myproject import app
if __name__ == "__main__":
app.run()
myproject.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
#location of log files
logto = /var/log/uwsgi/%n.log
I also created a systemd Unit file
/etc/systemd/system/myproject.service
[Unit]
Description=uWSGI instance serve myproject
After=network.target
[Service]
User = john
Group = www-data
WorkingDirectory=/var/www/flaskapp/
Environment="PATH=/var/www/flaskapp/venv/bin"
ExecStart=/var/www/flaskapp/venv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
and then
sudo systemctl start myproject
sudo systemctl enable myproject
Than configuration of nginx. nginx.conf I left unchanged but made corrections to /etc/nginx/sites-availible/myproject
server
listen 83;
server_name my_external_ip;
location /
include uwsgi_params;
uwsgi_pass unix:/var/www/flaskapp/flaskapp;
and made also a link to /etc/nginx/sites-enabled by command
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
After that: sudo systemctl restart nginx and sudo ufw allow 'Nginx Full'.
Now when I enter http://my_ip_address:83/ I see default nginx greeting and nothing else! Altough I think it should be my Hello There! made by my python-script. Don't know why...
Here is my logs:
/var/log/nginx/error.log
2018/02/08 22:17:51 [error] 2394#2394: *1 connect() to unix:/var/www/flaskapp/venv failed (111: Connection refused) while connecting to upstream, client: 46.146.0.30, server: 92.240.202.184, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/www/flaskapp/venv:", host: "my_external_ip:83"
And log of uwsgi:
current working directory: /var/www/flaskapp
detected binary path: /var/www/flaskapp/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 7157
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 myproject.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xf07550
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436560 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xf07550 pid: 2320 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2320)
spawned uWSGI worker 1 (pid: 2703, cores: 1)
spawned uWSGI worker 2 (pid: 2704, cores: 1)
spawned uWSGI worker 3 (pid: 2705, cores: 1)
spawned uWSGI worker 4 (pid: 2706, cores: 1)
spawned uWSGI worker 5 (pid: 2707, cores: 1)
Somewhere has been said that I need to reinstall uwsgi and also install pcre, but after doing this still no success, I really tried and searched all solutions related to this but with all effort I am getting nothing..
Please help me to detect problem and then to handle it...
Any help will be appreciated!
Thanks in advance!
nginx uwsgi
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Wht does the error sayupstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to beunix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and runlsof -p PID
to see what socket it actually has opened.
â wurtel
Feb 9 at 8:48
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Please do not hurry to close it as duplicate. I searched through the web and still cannot find the way to make it work.
This is my working directory:
/var/www/flaskapp
- myproject.ini
- myproject.py
- myproject.sock
pycache- venv
- wsgi.py
myproject.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
wsgi.py
from myproject import app
if __name__ == "__main__":
app.run()
myproject.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
#location of log files
logto = /var/log/uwsgi/%n.log
I also created a systemd Unit file
/etc/systemd/system/myproject.service
[Unit]
Description=uWSGI instance serve myproject
After=network.target
[Service]
User = john
Group = www-data
WorkingDirectory=/var/www/flaskapp/
Environment="PATH=/var/www/flaskapp/venv/bin"
ExecStart=/var/www/flaskapp/venv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
and then
sudo systemctl start myproject
sudo systemctl enable myproject
Than configuration of nginx. nginx.conf I left unchanged but made corrections to /etc/nginx/sites-availible/myproject
server
listen 83;
server_name my_external_ip;
location /
include uwsgi_params;
uwsgi_pass unix:/var/www/flaskapp/flaskapp;
and made also a link to /etc/nginx/sites-enabled by command
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
After that: sudo systemctl restart nginx and sudo ufw allow 'Nginx Full'.
Now when I enter http://my_ip_address:83/ I see default nginx greeting and nothing else! Altough I think it should be my Hello There! made by my python-script. Don't know why...
Here is my logs:
/var/log/nginx/error.log
2018/02/08 22:17:51 [error] 2394#2394: *1 connect() to unix:/var/www/flaskapp/venv failed (111: Connection refused) while connecting to upstream, client: 46.146.0.30, server: 92.240.202.184, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/www/flaskapp/venv:", host: "my_external_ip:83"
And log of uwsgi:
current working directory: /var/www/flaskapp
detected binary path: /var/www/flaskapp/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 7157
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 myproject.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xf07550
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436560 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xf07550 pid: 2320 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2320)
spawned uWSGI worker 1 (pid: 2703, cores: 1)
spawned uWSGI worker 2 (pid: 2704, cores: 1)
spawned uWSGI worker 3 (pid: 2705, cores: 1)
spawned uWSGI worker 4 (pid: 2706, cores: 1)
spawned uWSGI worker 5 (pid: 2707, cores: 1)
Somewhere has been said that I need to reinstall uwsgi and also install pcre, but after doing this still no success, I really tried and searched all solutions related to this but with all effort I am getting nothing..
Please help me to detect problem and then to handle it...
Any help will be appreciated!
Thanks in advance!
nginx uwsgi
Please do not hurry to close it as duplicate. I searched through the web and still cannot find the way to make it work.
This is my working directory:
/var/www/flaskapp
- myproject.ini
- myproject.py
- myproject.sock
pycache- venv
- wsgi.py
myproject.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
wsgi.py
from myproject import app
if __name__ == "__main__":
app.run()
myproject.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
#location of log files
logto = /var/log/uwsgi/%n.log
I also created a systemd Unit file
/etc/systemd/system/myproject.service
[Unit]
Description=uWSGI instance serve myproject
After=network.target
[Service]
User = john
Group = www-data
WorkingDirectory=/var/www/flaskapp/
Environment="PATH=/var/www/flaskapp/venv/bin"
ExecStart=/var/www/flaskapp/venv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
and then
sudo systemctl start myproject
sudo systemctl enable myproject
Than configuration of nginx. nginx.conf I left unchanged but made corrections to /etc/nginx/sites-availible/myproject
server
listen 83;
server_name my_external_ip;
location /
include uwsgi_params;
uwsgi_pass unix:/var/www/flaskapp/flaskapp;
and made also a link to /etc/nginx/sites-enabled by command
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
After that: sudo systemctl restart nginx and sudo ufw allow 'Nginx Full'.
Now when I enter http://my_ip_address:83/ I see default nginx greeting and nothing else! Altough I think it should be my Hello There! made by my python-script. Don't know why...
Here is my logs:
/var/log/nginx/error.log
2018/02/08 22:17:51 [error] 2394#2394: *1 connect() to unix:/var/www/flaskapp/venv failed (111: Connection refused) while connecting to upstream, client: 46.146.0.30, server: 92.240.202.184, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/www/flaskapp/venv:", host: "my_external_ip:83"
And log of uwsgi:
current working directory: /var/www/flaskapp
detected binary path: /var/www/flaskapp/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 7157
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 myproject.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xf07550
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436560 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xf07550 pid: 2320 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2320)
spawned uWSGI worker 1 (pid: 2703, cores: 1)
spawned uWSGI worker 2 (pid: 2704, cores: 1)
spawned uWSGI worker 3 (pid: 2705, cores: 1)
spawned uWSGI worker 4 (pid: 2706, cores: 1)
spawned uWSGI worker 5 (pid: 2707, cores: 1)
Somewhere has been said that I need to reinstall uwsgi and also install pcre, but after doing this still no success, I really tried and searched all solutions related to this but with all effort I am getting nothing..
Please help me to detect problem and then to handle it...
Any help will be appreciated!
Thanks in advance!
nginx uwsgi
asked Feb 8 at 17:24
John
177212
177212
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Wht does the error sayupstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to beunix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and runlsof -p PID
to see what socket it actually has opened.
â wurtel
Feb 9 at 8:48
add a comment |Â
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Wht does the error sayupstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to beunix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and runlsof -p PID
to see what socket it actually has opened.
â wurtel
Feb 9 at 8:48
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Wht does the error say
upstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to be unix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and run lsof -p PID
to see what socket it actually has opened.â wurtel
Feb 9 at 8:48
Wht does the error say
upstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to be unix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and run lsof -p PID
to see what socket it actually has opened.â wurtel
Feb 9 at 8:48
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422868%2fnginx-connection-refused-error-111-bad-gateway%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Just a thought: have you checked file permissions? Esp. the permissions of your python scripts; does the uwsgi runtime user has the permissions to read and execute the scripts, are the directories leading to /var/wwwflaskapp world world readable and executable as well?
â Stefan
Feb 8 at 21:44
Sure! That's the first what I checked
â John
Feb 9 at 5:00
Wht does the error say
upstream: "uwsgi://unix:/var/www/flaskapp/venv:
when you have defined the upstream to beunix:/var/www/flaskapp/flaskapp
? Find the uwsgi process ID, and runlsof -p PID
to see what socket it actually has opened.â wurtel
Feb 9 at 8:48