Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Thanks, great tutorial!
Although I am having a problem and I hope you could help.
.service
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=deploy
Group=www-data
WorkingDirectory=/home/deploy/flasktest
Environment="PATH=/home/deploy/.virtualenv/flasktest/bin"
ExecStart=/home/deploy/.virtualenv/flasktest/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 manage:app
[Install]
WantedBy=multi-user.target
configuration file in Nginx’s
server {
listen 80;
server_name 100.10.10.20;
location / {
include proxy_params;
proxy_pass http://unix:/home/deploy/flasktest/flasktest.sock;
}
}
But if I connect to the address I get a “502 Bad Gateway” response…
2016/05/26 16:53:16 [error] 1052#0: *191 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.74.110, server: _, request: "GET /home/ HTTP/1.1", upstream: "http://unix:/home/deploy/flasktest/flasktest.sock:/", host: "100.10.10.20"
This comment has been deleted
Thanks, great tutorial! I follow this and it worked, just 1 thing to note. In my up to date ubuntu16.04(June 24) , In Configuring Nginx to Proxy Requests section, in /etc/nginx/sites-enabled folder ,there is a “default” file. fisrt time I enter http://server_domain_or_IP in browser ,get nginx welcome page. We should remove this file to get our ‘hello there’ page.
Hi, My name is sender, and a trying to finish this instalation, but I dont know whats is the problem. 502, bad gateway. when simulation occurs, it appears the “hello there”, but when I try to activate the second part appears this error, I am sending my settings…
\etc\nginx/nginx.conf
server { listen 80; server_name 10.0.0.50;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/sender/meuprojeto2/meuprojeto2.sock;
}
}
/etc/systemd/system/meuprojeto.service
[Unit] Description=uwsgi instance to serve meuprojeto2 After=network.target
[Service] User=sender Group=nginx WorkingDirectory=/home/sender/meuprojeto2 Environment=“PATH=/home/sender/meuprojeto2/meuprojeto2env/bin” ExecStart=/home/sender/meuprojeto2/meuprojeto2env/bin/uwsgi --ini meuprojeto2.ini
[Install] WantedBy=multi-user.target
To clarify in case anyone else has this problem:
In the file: /etc/systemd/system/myproject.service
This line: ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
On our system it turns out gunicorn is not located here: /home/sammy/myproject/myprojectenv/bin/gunicorn
rather it is located here: /usr/local/bin/gunicorn
It took our apprentice several days to figure this one out. You might want to clarify this alternative.
I followed the steps exactly and in the end I got the “Hello There!” message to show up at my server’s IP address. However, when I rebooted my server and ssh’ed in, I could not get it to work. After that I could no longer connect and get the “Hello There!” message to appear. I get the same message that the IP address refused to connect.
I followed the example but I get error 502. When I checked the error logs at /var/log/nginx/error.log. It says no directory or file /home/dapo/myproject/myproject.sock
I fix it, since the myproject.sock has to be created by gunicorn, all I did is to restart gunicorn like “sudo systemctl restart myproject” then I did “sudo systemctl restart nginx” and it works
I am still getting the 502 Gateway error. I have checked the log of nginx and it says there is no "/home/root/myproject/myproject.sock file. Like the last the last person to post a question I have double checked my setup files. Here is the error.log file:
2016/08/11 12:10:41 [emerg] 13854#13854: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:10:41 [emerg] 13854#13854: still could not bind() 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: listen() to [::]:80, backlog 511 failed (98: Address already in use) 2016/08/11 12:29:50 [emerg] 14125#14125: still could not bind() 2016/08/11 13:43:46 [emerg] 14499#14499: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:43:46 [emerg] 14499#14499: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:43:46 [emerg] 14499#14499: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:43:46 [emerg] 14499#14499: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:43:46 [emerg] 14499#14499: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:43:46 [emerg] 14499#14499: still could not bind() 2016/08/11 13:45:21 [emerg] 14535#14535: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:45:21 [emerg] 14535#14535: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:45:21 [emerg] 14535#14535: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:45:21 [emerg] 14535#14535: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:45:21 [emerg] 14535#14535: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:45:21 [emerg] 14535#14535: still could not bind() 2016/08/11 13:48:55 [emerg] 14644#14644: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:48:55 [emerg] 14644#14644: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:48:55 [emerg] 14644#14644: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:48:55 [emerg] 14644#14644: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:48:55 [emerg] 14644#14644: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) 2016/08/11 13:48:55 [emerg] 14644#14644: still could not bind() 2016/08/11 13:51:55 [crit] 14722#14722: *1 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/”, host: “188.166.226.199” 2016/08/11 13:51:55 [crit] 14722#14722: *3 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/favicon.ico”, host: “188.166.226.199”, referrer: “http://188.166.226.199/” 2016/08/11 14:01:44 [crit] 14870#14870: *1 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/”, host: “188.166.226.199” 2016/08/11 14:09:54 [crit] 14870#14870: *3 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/”, host: “188.166.226.199” 2016/08/11 14:10:16 [crit] 14870#14870: *5 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/”, host: “188.166.226.199” 2016/08/11 14:12:34 [crit] 14955#14955: *1 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/”, host: “188.166.226.199” 2016/08/11 14:12:34 [crit] 14955#14955: *3 connect() to unix:/home/root/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 61.93.120.56, server: 188.166.226.199, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://unix:/home/root/myproject/myproject.sock:/favicon.ico”, host: “188.166.226.199”, referrer: “http://188.166.226.199/” root@ianwj:~# sudo systemctl restart myproject root@ianwj:~# sudo systemctl restart nginx root@ianwj:~# cd myproject root@ianwj:~/myproject# ls myproject.py myproject.pyc myprojectenv wsgi.py wsgi.pyc root@ianwj:~/myproject# cd etc/nginx/sites-available -bash: cd: etc/nginx/sites-available: No such file or directory
Sorry for the longwinded post…
I am very frustrated by the fact that at times, I get an error 502 bad gateway error or an error 500 internal server error. This will go away when I run the sudo systemctl restart myproject and after some days it comes back and this is really affecting my business.
When I check my error logs I often get this
2016/10/20 23:37:18 [crit] 12366#12366: *47260 connect() to unix:/home/myusername/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 78.206.179.140, server: 000.111.222.333, request: “GET /goods HTTP/1.1”, upstream: “http://unix:/home/myusername/myproject/myproject.sock:/goods”, host: “000.111.222.333”, referrer: “http://000.111.222.333/goods”
Can it just work well once and for all or does it just kills it connections.