I just want to know, if in this community, there are some users who have been able to configure their site for django - gunicorn - nginx following the tutorial steps
Has managed to run its application and that is also visible in production by the number of ip and / or the domain name “www.xxxxxx.xx” and does not appear BAD 502. only that ??? If it works please report that you had success, to clear if there is something in my procedure or is some bug, suddenly if some I achieved using another system for example as dbain, please report please.
I have my doubts, since practically in all the forums my problem is in the air without RESOlVER.
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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Well every time I get more clear this matter, but I still can not run my application.
I commented that the application is at zero only has the minimum parameters in “settings.py” so that I launch “its work” from django.
I did everything carefully, according to the guide that you sent me and although it really helped me a lot I did not deploy the site, I only get the welcome to “nginx” and accessing the domain launches the welcome page of nginx, but accessing by ip Throw me bad 502.
Important thing I noticed, is that I do not see anywhere a “myproject.sock” file or I do not know where it is and checking the error log gives me the following.
Can you see that can be happening please ??
root@max:/home/max/myproject/myproject# sudo systemctl status gunicorn● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2017-04-12 22:09:50 UTC; 12min ago Main PID: 24464 (code=exited, status=1/FAILURE)
Apr 12 22:09:45 max gunicorn[24464]: [2017-04-12 22:09:45 +0000] [24464] [INFO] Starting gunicor Apr 12 22:09:45 max gunicorn[24464]: [2017-04-12 22:09:45 +0000] [24464] [ERROR] Retrying in 1 s Apr 12 22:09:46 max gunicorn[24464]: [2017-04-12 22:09:46 +0000] [24464] [ERROR] Retrying in 1 s Apr 12 22:09:47 max gunicorn[24464]: [2017-04-12 22:09:47 +0000] [24464] [ERROR] Retrying in 1 s Apr 12 22:09:48 max gunicorn[24464]: [2017-04-12 22:09:48 +0000] [24464] [ERROR] Retrying in 1 s Apr 12 22:09:49 max gunicorn[24464]: [2017-04-12 22:09:49 +0000] [24464] [ERROR] Retrying in 1 s Apr 12 22:09:50 max gunicorn[24464]: [2017-04-12 22:09:50 +0000] [24464] [ERROR] Can’t connect t Apr 12 22:09:50 max systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAI Apr 12 22:09:50 max systemd[1]: gunicorn.service: Unit entered failed state. Apr 12 22:09:50 max systemd[1]: gunicorn.service: Failed with result ‘exit-code’.
and log error:
2017/04/12 22:16:26 [crit] 24587#24587: *1 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:16:41 [crit] 24587#24587: *1 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:22:58 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:04 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:40 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:30:29 [crit] 24587#24587: *11 connect() to unix:/home/max/myproject/myproject.soc$ 2017/04/12 22:30:29 [crit] 24587#24587: *13 connect() to unix:/home/max/myproject/myproject.soc$
$t.sock failed (2: No such file or directory) while connecting to upstream, client: 181.163.181$ 2017/04/12 22:16:41 [crit] 24587#24587: *1 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:22:58 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:04 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:40 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:30:29 [crit] 24587#24587: *11 connect() to unix:/home/max/myproject/myproject.soc$ 2017/04/12 22:30:29 [crit] 24587#24587: *13 connect() to unix:/home/max/myproject/myproject.soc$
$63.181.193, server: 67.207.84.106, request: “GET / HTTP/1.1”, upstream: "http://unix:/home/max$ 2017/04/12 22:16:41 [crit] 24587#24587: *1 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:22:58 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:04 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:23:40 [crit] 24587#24587: *6 connect() to unix:/home/max/myproject/myproject.sock$ 2017/04/12 22:30:29 [crit] 24587#24587: *11 connect() to unix:/home/max/myproject/myproject.soc$ 2017/04/12 22:30:29 [crit] 24587#24587: *13 connect() to unix:/home/max/myproject/myproject.soc$
its so importan for me, that you givme a direction to do
@maxgonpe
For Python 3, my test consisted of the following commands. I used
max
as the username here since that’s what you wanted to use, so you should be able to simply copy and paste my commands in to terminal (MacOS), PuTTy (Windows), etc.You can copy and paste multi-line commands directly in as well (I use them to prevent having to enter in single line commands and speed things up a bit).
Find
ALLOWED_HOSTS = []
and add your Droplet’s Public IPv4 IP there so that it looks like this (change111.222.333.444
to your IP).Find:
Replace it with (I used the defaults, you’ll need to change
NAME
,USER
,PASSWORD
to match).At the bottom of the file, find
STATIC_URL = '/static/'
and directly below it add:CTRL + X and save the file. Then run:
You’ll be asked to create a user. Choose whatever username and password you’d like. That’s what you’ll login to the admin panel with once the project is live.
For the time being, skip all the firewall rules in the guide. With Ubuntu,
ufw
(the firewall) is off by default, so let’s not worry about those rules just yet. Well move on to the rest of the setup.Let’s make sure the project can be served now.
If you can access the project on port 8000, let’s see if Gunicorn works now. Hit CTRL + C to exit the server.
If that works too, so far so good :-). Hit CTRL + C to exit the server and then run
deactivate
to kill off the virtual env.Now we need to make sure all the files inside the home directory are owned by
max
otherwise thesystemd
file we create will fail to create the socket. So let’s run:Now we’ll setup the
systemd
file.Within that paste in:
Hit CTRL + X and save the file. Now run:
Now we’ll setup the NGINX server block:
Within that file, paste:
You need to change
server_name server_domain_or_IP;
by replacingserver_domain_or_IP
with the IP of your Droplet. So it should look like:Where
111.222.333.444
is your IP. CTRL + X and save the file.Create the required symlink:
Test the configuration:
Restart NGINX:
You’ll need to refer back to the guide on setting up the Postgres Database, though the above should get you up and working with Python 3. I just tested this with each of the commands I just used above.
@jtittle any way , thanks