Django deploy Gunicorn and NginX












0















While trying to finally deploy my NEW rover web app a problem occured. I already configured Gunicorn and bind it to 0.0.0.0:80 (with wsgi). Website loads, but without any images, css, javascript files (even "admin" site is without any style). Postgres is installed and running fine. I already did



python manage.py collectstatic
python manage.py migrate


I watched tons of tutorials how to do it. But still after I try to run:



systemctl status nginx.service


i get an error:



Job for nginx.service failed because the control process exited with error code. 
See "systemctl status nginx.service" and "journalctl -xe" for details.


#systemctl status nginx.service output:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since śro 2018-11-28 02:57:12 CET; 1min 13s ago
Process: 14721 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 25481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 10279 (code=exited, status=0/SUCCESS)

nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.




#journalctl -xe output:

sshd[5669]: Received disconnect from 181.15.216.20 port 42140:11: Bye Bye [preauth]
sshd[5669]: Disconnected from 181.15.216.20 port 42140 [preauth]
sudo[5773]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/systemctl restart nginx
sudo[5773]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)
systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has finished shutting down.
systemd[1]: Starting A high performance web server and a reverse proxy server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address aginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)lready in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)


/etc/systemd/system/gunicorn.socket file:



[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target


/etc/systemd/system/gunicorn.service file:



[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=djangosu
Group=djangosu
WorkingDirectory=/home/djangosu/website/rover-Project
ExecStart=/home/djangosu/website/rover-env/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
rover.wsgi:application

[Install]
WantedBy=multi-user.target


And "rover" file (the same as name of project) in sites-available (I already linked it to sites-enabled):



server {
listen 80;
server_name :333 ;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/.../website/rover/rover;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}


gunicorn.sock exists in /run/ dir.... Any suggestions ?



Release note:



Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial









share|improve this question























  • Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

    – Daniel Roseman
    Nov 28 '18 at 9:10











  • No. Apache is inactive

    – DrJoe
    Nov 29 '18 at 10:36
















0















While trying to finally deploy my NEW rover web app a problem occured. I already configured Gunicorn and bind it to 0.0.0.0:80 (with wsgi). Website loads, but without any images, css, javascript files (even "admin" site is without any style). Postgres is installed and running fine. I already did



python manage.py collectstatic
python manage.py migrate


I watched tons of tutorials how to do it. But still after I try to run:



systemctl status nginx.service


i get an error:



Job for nginx.service failed because the control process exited with error code. 
See "systemctl status nginx.service" and "journalctl -xe" for details.


#systemctl status nginx.service output:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since śro 2018-11-28 02:57:12 CET; 1min 13s ago
Process: 14721 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 25481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 10279 (code=exited, status=0/SUCCESS)

nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.




#journalctl -xe output:

sshd[5669]: Received disconnect from 181.15.216.20 port 42140:11: Bye Bye [preauth]
sshd[5669]: Disconnected from 181.15.216.20 port 42140 [preauth]
sudo[5773]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/systemctl restart nginx
sudo[5773]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)
systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has finished shutting down.
systemd[1]: Starting A high performance web server and a reverse proxy server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address aginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)lready in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)


/etc/systemd/system/gunicorn.socket file:



[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target


/etc/systemd/system/gunicorn.service file:



[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=djangosu
Group=djangosu
WorkingDirectory=/home/djangosu/website/rover-Project
ExecStart=/home/djangosu/website/rover-env/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
rover.wsgi:application

[Install]
WantedBy=multi-user.target


And "rover" file (the same as name of project) in sites-available (I already linked it to sites-enabled):



server {
listen 80;
server_name :333 ;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/.../website/rover/rover;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}


gunicorn.sock exists in /run/ dir.... Any suggestions ?



Release note:



Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial









share|improve this question























  • Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

    – Daniel Roseman
    Nov 28 '18 at 9:10











  • No. Apache is inactive

    – DrJoe
    Nov 29 '18 at 10:36














0












0








0








While trying to finally deploy my NEW rover web app a problem occured. I already configured Gunicorn and bind it to 0.0.0.0:80 (with wsgi). Website loads, but without any images, css, javascript files (even "admin" site is without any style). Postgres is installed and running fine. I already did



python manage.py collectstatic
python manage.py migrate


I watched tons of tutorials how to do it. But still after I try to run:



systemctl status nginx.service


i get an error:



Job for nginx.service failed because the control process exited with error code. 
See "systemctl status nginx.service" and "journalctl -xe" for details.


#systemctl status nginx.service output:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since śro 2018-11-28 02:57:12 CET; 1min 13s ago
Process: 14721 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 25481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 10279 (code=exited, status=0/SUCCESS)

nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.




#journalctl -xe output:

sshd[5669]: Received disconnect from 181.15.216.20 port 42140:11: Bye Bye [preauth]
sshd[5669]: Disconnected from 181.15.216.20 port 42140 [preauth]
sudo[5773]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/systemctl restart nginx
sudo[5773]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)
systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has finished shutting down.
systemd[1]: Starting A high performance web server and a reverse proxy server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address aginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)lready in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)


/etc/systemd/system/gunicorn.socket file:



[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target


/etc/systemd/system/gunicorn.service file:



[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=djangosu
Group=djangosu
WorkingDirectory=/home/djangosu/website/rover-Project
ExecStart=/home/djangosu/website/rover-env/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
rover.wsgi:application

[Install]
WantedBy=multi-user.target


And "rover" file (the same as name of project) in sites-available (I already linked it to sites-enabled):



server {
listen 80;
server_name :333 ;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/.../website/rover/rover;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}


gunicorn.sock exists in /run/ dir.... Any suggestions ?



Release note:



Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial









share|improve this question














While trying to finally deploy my NEW rover web app a problem occured. I already configured Gunicorn and bind it to 0.0.0.0:80 (with wsgi). Website loads, but without any images, css, javascript files (even "admin" site is without any style). Postgres is installed and running fine. I already did



python manage.py collectstatic
python manage.py migrate


I watched tons of tutorials how to do it. But still after I try to run:



systemctl status nginx.service


i get an error:



Job for nginx.service failed because the control process exited with error code. 
See "systemctl status nginx.service" and "journalctl -xe" for details.


#systemctl status nginx.service output:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since śro 2018-11-28 02:57:12 CET; 1min 13s ago
Process: 14721 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 25481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 10279 (code=exited, status=0/SUCCESS)

nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[25481]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.




#journalctl -xe output:

sshd[5669]: Received disconnect from 181.15.216.20 port 42140:11: Bye Bye [preauth]
sshd[5669]: Disconnected from 181.15.216.20 port 42140 [preauth]
sudo[5773]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/systemctl restart nginx
sudo[5773]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)
systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has finished shutting down.
systemd[1]: Starting A high performance web server and a reverse proxy server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address aginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)lready in use)
nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx[5957]: nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
sudo[5773]: pam_unix(sudo:session): session closed for user root
sudo[6331]: djangosu : TTY=pts/5 ; PWD=/home/djangosu ; USER=root ; COMMAND=/bin/journalctl -xe
sudo[6331]: pam_unix(sudo:session): session opened for user root by djangosu(uid=0)


/etc/systemd/system/gunicorn.socket file:



[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target


/etc/systemd/system/gunicorn.service file:



[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=djangosu
Group=djangosu
WorkingDirectory=/home/djangosu/website/rover-Project
ExecStart=/home/djangosu/website/rover-env/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn.sock
rover.wsgi:application

[Install]
WantedBy=multi-user.target


And "rover" file (the same as name of project) in sites-available (I already linked it to sites-enabled):



server {
listen 80;
server_name :333 ;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/.../website/rover/rover;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}


gunicorn.sock exists in /run/ dir.... Any suggestions ?



Release note:



Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial






django gunicorn nginx-config






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 2:19









DrJoeDrJoe

205




205













  • Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

    – Daniel Roseman
    Nov 28 '18 at 9:10











  • No. Apache is inactive

    – DrJoe
    Nov 29 '18 at 10:36



















  • Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

    – Daniel Roseman
    Nov 28 '18 at 9:10











  • No. Apache is inactive

    – DrJoe
    Nov 29 '18 at 10:36

















Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

– Daniel Roseman
Nov 28 '18 at 9:10





Well, it's telling you that you already have something bound to port 80. Do you? For example, are you also running Apache?

– Daniel Roseman
Nov 28 '18 at 9:10













No. Apache is inactive

– DrJoe
Nov 29 '18 at 10:36





No. Apache is inactive

– DrJoe
Nov 29 '18 at 10:36












1 Answer
1






active

oldest

votes


















0














nginx is telling you, it cannot bind to port 80 as some other process is already listening on this port. You can see this in your log output here:




nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)




To check which process is listening on this port you could use netstat or better ss:




~# ss -naptu state listening | grep :80
tcp 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=6824,fd=4),("nginx",pid=6823,fd=4))



~# netstat -tulpen | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 136280382 6823/nginx: master


The last column will show the process name and the pid of the process listening on the port.






share|improve this answer
























  • well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

    – DrJoe
    Nov 28 '18 at 20:26













  • gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

    – Daniel Roseman
    Nov 29 '18 at 10:37











  • Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

    – Walter Reiner
    Nov 29 '18 at 10:39













  • I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

    – Walter Reiner
    Nov 29 '18 at 11:07











  • My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

    – Daniel Roseman
    Nov 29 '18 at 11:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511151%2fdjango-deploy-gunicorn-and-nginx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














nginx is telling you, it cannot bind to port 80 as some other process is already listening on this port. You can see this in your log output here:




nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)




To check which process is listening on this port you could use netstat or better ss:




~# ss -naptu state listening | grep :80
tcp 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=6824,fd=4),("nginx",pid=6823,fd=4))



~# netstat -tulpen | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 136280382 6823/nginx: master


The last column will show the process name and the pid of the process listening on the port.






share|improve this answer
























  • well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

    – DrJoe
    Nov 28 '18 at 20:26













  • gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

    – Daniel Roseman
    Nov 29 '18 at 10:37











  • Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

    – Walter Reiner
    Nov 29 '18 at 10:39













  • I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

    – Walter Reiner
    Nov 29 '18 at 11:07











  • My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

    – Daniel Roseman
    Nov 29 '18 at 11:14
















0














nginx is telling you, it cannot bind to port 80 as some other process is already listening on this port. You can see this in your log output here:




nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)




To check which process is listening on this port you could use netstat or better ss:




~# ss -naptu state listening | grep :80
tcp 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=6824,fd=4),("nginx",pid=6823,fd=4))



~# netstat -tulpen | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 136280382 6823/nginx: master


The last column will show the process name and the pid of the process listening on the port.






share|improve this answer
























  • well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

    – DrJoe
    Nov 28 '18 at 20:26













  • gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

    – Daniel Roseman
    Nov 29 '18 at 10:37











  • Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

    – Walter Reiner
    Nov 29 '18 at 10:39













  • I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

    – Walter Reiner
    Nov 29 '18 at 11:07











  • My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

    – Daniel Roseman
    Nov 29 '18 at 11:14














0












0








0







nginx is telling you, it cannot bind to port 80 as some other process is already listening on this port. You can see this in your log output here:




nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)




To check which process is listening on this port you could use netstat or better ss:




~# ss -naptu state listening | grep :80
tcp 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=6824,fd=4),("nginx",pid=6823,fd=4))



~# netstat -tulpen | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 136280382 6823/nginx: master


The last column will show the process name and the pid of the process listening on the port.






share|improve this answer













nginx is telling you, it cannot bind to port 80 as some other process is already listening on this port. You can see this in your log output here:




nginx[5957]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)




To check which process is listening on this port you could use netstat or better ss:




~# ss -naptu state listening | grep :80
tcp 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=6824,fd=4),("nginx",pid=6823,fd=4))



~# netstat -tulpen | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 136280382 6823/nginx: master


The last column will show the process name and the pid of the process listening on the port.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 11:50









Walter ReinerWalter Reiner

11




11













  • well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

    – DrJoe
    Nov 28 '18 at 20:26













  • gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

    – Daniel Roseman
    Nov 29 '18 at 10:37











  • Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

    – Walter Reiner
    Nov 29 '18 at 10:39













  • I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

    – Walter Reiner
    Nov 29 '18 at 11:07











  • My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

    – Daniel Roseman
    Nov 29 '18 at 11:14



















  • well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

    – DrJoe
    Nov 28 '18 at 20:26













  • gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

    – Daniel Roseman
    Nov 29 '18 at 10:37











  • Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

    – Walter Reiner
    Nov 29 '18 at 10:39













  • I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

    – Walter Reiner
    Nov 29 '18 at 11:07











  • My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

    – Daniel Roseman
    Nov 29 '18 at 11:14

















well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

– DrJoe
Nov 28 '18 at 20:26







well it doesn't surprise me: tcp 0 128 :80 *: users:(("gunicorn",pid=23983,fd=5),("gunicorn",pid=15125,fd=5)). But isn't that something like: request from "guest" -> nginx -> unicorn -> django module -> website generated for "guest". Should I disable gunicorn ... ? It doesn't make any sense...

– DrJoe
Nov 28 '18 at 20:26















gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

– Daniel Roseman
Nov 29 '18 at 10:37





gunicorn is supposed to be bound to the socket, not to a port. Are you running it twice?

– Daniel Roseman
Nov 29 '18 at 10:37













Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

– Walter Reiner
Nov 29 '18 at 10:39







Yes you're basically right. You have the problem, that gunicorn needs to use a different port than your nginx. I let my gunicorn listen on the internal interface and a specific port with the bind parameter. You can set it in your gunicorn conf or with a command line parameter like "gunicorn -b 127.0.0.1:8080". You need to change your nginx config to proxy to this adress. I could update my original answer if you need more info on this.

– Walter Reiner
Nov 29 '18 at 10:39















I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

– Walter Reiner
Nov 29 '18 at 11:07





I think @DanielRoseman is on the better way though - you could check with "ps -ef | grep gunicorn" which gunicorn processes are running.

– Walter Reiner
Nov 29 '18 at 11:07













My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

– Daniel Roseman
Nov 29 '18 at 11:14





My point was the code as posted in the question shows gunicorn binding to a socket anyway; it shouldn't be using a port at all.

– Daniel Roseman
Nov 29 '18 at 11:14




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511151%2fdjango-deploy-gunicorn-and-nginx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)