I was deploying my Django project on fedora 33 nginx server. But domain and localhost tell me 502 bad gateway. I made diagnostic and learned that:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2021-01-08 01:34:08 +04; 1min 17s ago
Process: 4348 ExecStart=/home/robot/venv/bin/gunicorn --workers 3
--bind unix:/home/robot/plagiat/plagiat.sock plagiat.wsgi:application (code=exited, status=203/EXEC)
Main PID: 4348 (code=exited, status=203/EXEC) CPU: 5ms
Jan 08 01:34:10 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:10 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:10 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:10 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:11 baku systemd[1]: Failed to start gunicorn daemon.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Start request repeated too quickly.
Jan 08 01:34:11 baku systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jan 08 01:34:11 baku systemd[1]: Failed to start gunicorn daemon.
Related
I'm trying a deploy simple Django application on Digital Ocean by following this [link][1] I follow every work step by step and successfully run that project via python manage.py runserver where it's not throwing any error but when I try to implement it with gunicorn its throw following error
gunicorn.service: Failed with result 'exit-code'.
Here is my following configuration:
sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=pos
Group=www-data
WorkingDirectory=/home/pos/pos
ExecStart=/home/pos/env/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
pos.wsgi:application
[Install]
WantedBy=multi-user.target
sudo systemctl status gunicorn.socket
● gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: active (listening) since Tue 2019-11-26 07:39:39 UTC; 12min ago
Listen: /run/gunicorn.sock (Stream)
CGroup: /system.slice/gunicorn.socket
Nov 26 07:39:39 POS systemd[1]: Listening on gunicorn socket.
When I try to start gunicorn it's throwing this error
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 Tue 2019-11-26 07:39:43 UTC; 13min ago
Process: 718 ExecStart=/home/pos/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock pos.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 718 (code=exited, status=1/FAILURE)
Nov 26 07:39:43 POS gunicorn[718]: Arbiter(self).run()
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 198, in run
Nov 26 07:39:43 POS gunicorn[718]: self.start()
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 155, in start
Nov 26 07:39:43 POS gunicorn[718]: self.LISTENERS = sock.create_sockets(self.cfg, self.log, fds)
Nov 26 07:39:43 POS gunicorn[718]: File "/home/pos/env/lib/python3.7/site-packages/gunicorn/sock.py", line 172, in create_sockets
Nov 26 07:39:43 POS gunicorn[718]: sock_name = sock.getsockname()
Nov 26 07:39:43 POS gunicorn[718]: OSError: getsockaddrlen: bad family
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Anyone helps me to solve this issue?
[1]: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
The latest version of gunicorn (20.0.3) can cause this problem.
Try installing an older version of gunicorn:
pip install gunicorn==20.0.2
It seems that you are trying to listen to unix:/run/gunicorn.sock in ExecStart, but the socket is at run/gunicorn.socket. Try changing this and run systemctl daemon-reload to see if it makes a difference.
I changed the postgres data directory following these steps:
systemctl stop postgresql-11.service
cp -r /var/lib/pgsql/11/data /home/eshel/pgsql-11/
chown -R postgres:postgres /home/eshel/pgsql-11/
chmod 700 /home/eshel/pgsql-11/
vi /usr/lib/systemd/system/postgresql-11.service
Environment=PGDATA=/home/eshel/pgsql-11/data/
systemctl daemon-reload
systemctl start postgresql-11.service
So far, the postgres-11 is normal.
After I changed the new data_directory's postgres.conf.
1. vim pgsql-11/data/postgresql.conf
data_directory = '/home/eshel/pgsql-11/data'
I can't start postgres-11. I don't know how to handle this.
The error follows:
[root#localhost 11]# systemctl start postgresql-11.service
* Job for postgresql-11.service failed because the control process exited with error code. See "systemctl status postgresql-11.service" and "journalctl -xe" for details.
[root#localhost 11]# systemctl status postgresql-11.service
● postgresql-11.service - PostgreSQL 11 database server
* Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled; vendor preset: disabled)
* Active: failed (Result: exit-code) since Fri 2019-10-11 23:05:00 CST; 27s ago
* Docs: https://www.postgresql.org/docs/11/static/
* Process: 12758 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
* Main PID: 11582 (code=exited, status=0/SUCCESS)
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
[root#localhost 11]# journalctl -xe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Activating service name='org.freedesktop.problems' (using servicehe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Successfully activated service 'org.freedesktop.problems'
* Oct 11 23:04:51 localhost.localdomain nautilus-deskto[9318]: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simpl
* Oct 11 23:05:00 localhost.localdomain polkitd[6478]: Registered Authentication Agent for unix-process:12752:1022414 (system bu
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* -- Subject: Unit postgresql-11.service has begun start-up
* -- Defined-By: systemd
* -- Unit postgresql-11.service has begun starting up.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: "/home/eshel/pgsql-11/data/" is missing or empty.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: Use "/usr/pgsql-11/bin/postgresql-11-setup initdb" to
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: See /usr/share/doc/postgresql11-11.4/README.rpm-dist
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* -- Subject: Unit postgresql-11.service has failed
* -- Defined-By: systemd
* -- Unit postgresql-11.service has failed.
* -- The result is failed.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
Process: 10839 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
The postgres can't read the PGDATA direcotry.With the help of someone else, We solved this by following:
Before modification:
drwx------. 19 eshel eshel 4096 Oct 12 21:00 eshel
After modification:
[root#localhost eshel]# chmod 755 ../eshel/
[root#localhost eshel]# ll ../
drwxr-xr-x. 19 eshel eshel 4096 Oct 12 21:00 eshel
Then I start postgres11, and it's OK!
systemctl start postgresql-11
Am trying to host a we application using gunicorn and nginx. But I cant start the gunicorn service. everytime am getting the error message.
This is the error am getting
(env) root#ip-172-31-21-54:/home/env# 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 Mon 2018-12-17 14:59:42 UTC; 488ms ago
Process: 14160 ExecStart=/home/ubuntu/env/bin/gunicorn --access-logfile - --
workers 3 --bind unix:/home/ubuntu/env/Project/Project.sock
Project.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 14160 (code=exited, status=1/FAILURE)
Dec 17 14:59:36 ip-172-31-21-54 systemd[1]: Started gunicorn daemon.
Dec 17 14:59:37 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:37 +0000]
[14160] [INFO] Starting gunicorn 19.9.0
Dec 17 14:59:37 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:37 +0000]
[14160] [ERROR] Retrying in 1 second.
Dec 17 14:59:38 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:38 +0000]
[14160] [ERROR] Retrying in 1 second.
Dec 17 14:59:39 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:39 +0000]
[14160] [ERROR] Retrying in 1 second.
Dec 17 14:59:40 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:40 +0000]
[14160] [ERROR] Retrying in 1 second.
Dec 17 14:59:41 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:41 +0000] [14160] [ERROR] Retrying in 1 second.
Dec 17 14:59:42 ip-172-31-21-54 gunicorn[14160]: [2018-12-17 14:59:42 +0000] [14160] [ERROR] Can't connect to /home/ubuntu/env/Project/Project.sock
Dec 17 14:59:42 ip-172-31-21-54 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Dec 17 14:59:42 ip-172-31-21-54 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
And My gunicorn.service file is
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/env/Project
ExecStart=/home/ubuntu/env/bin/gunicorn --access-logfile -
--workers 3 --bind unix:/home/ubuntu/env/Project/Project.sock
Project.wsgi:application
[Install]
WantedBy=multi-user.target
I cant find the error.. Please help me to solve this.
I've got a gunicorn script that fails to load.
Here's it's code
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/revamp
ExecStart=/home/sammy/revamp/revampenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/revamp/revamp.sock revamp.wsgi:application
[Install]
WantedBy=multi-user.target
and the response from status
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2017-07-19 14:17:56 UTC; 2min 1s ago
Process: 26564 ExecStart=/home/sammy/revamp/revampenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/revamp/revamp.sock revamp.wsgi:application (code=exited, status=1/FAI
Main PID: 26564 (code=exited, status=1/FAILURE)
Jul 19 14:17:51 samuel-pc gunicorn[26564]: [2017-07-19 14:17:51 +0000] [26564] [INFO] Starting gunicorn 19.7.1
Jul 19 14:17:51 samuel-pc gunicorn[26564]: [2017-07-19 14:17:51 +0000] [26564] [ERROR] Retrying in 1 second.
Jul 19 14:17:52 samuel-pc gunicorn[26564]: [2017-07-19 14:17:52 +0000] [26564] [ERROR] Retrying in 1 second.
Jul 19 14:17:53 samuel-pc gunicorn[26564]: [2017-07-19 14:17:53 +0000] [26564] [ERROR] Retrying in 1 second.
Jul 19 14:17:54 samuel-pc gunicorn[26564]: [2017-07-19 14:17:54 +0000] [26564] [ERROR] Retrying in 1 second.
Jul 19 14:17:55 samuel-pc gunicorn[26564]: [2017-07-19 14:17:55 +0000] [26564] [ERROR] Retrying in 1 second.
Jul 19 14:17:56 samuel-pc gunicorn[26564]: [2017-07-19 14:17:56 +0000] [26564] [ERROR] Can't connect to /home/sammy/revamp/revamp.sock
Jul 19 14:17:56 samuel-pc systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Jul 19 14:17:56 samuel-pc systemd[1]: gunicorn.service: Unit entered failed state.
Jul 19 14:17:56 samuel-pc systemd[1]: gunicorn.service: Failed with result 'exit-code'.
the sock file isn't created in the folder, what am I doing wrong?
Looks like the user that you are using to run gunicorn as a service (sammy) does not have permission to access the project folder.
You can check the folder permission with ls -l
To change them you can do:
sudo chown sammy:sammy /home/sammy/revamp
I installed Centos 7, 64 bit. Installed postgresql-9.4.
Initialized postgresql with command
/usr/pgsql-9.4/bin/postgresql94-setup initdb
then used this command to start postgresql
systemctl start postgresql-9.4
and showed error like this:
service failed because the control process exited with error code. See "systemctl status postgresql-9.4.service" and "journalctl -xe" for details.
entered command
systemctl status postgresql-9.4.service
● postgresql-9.4.service - PostgreSQL 9.4 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-03-02 18:09:27 CST; 1min 59s ago
Process: 31266 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)
Process: 31261 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >LOG: could not bind IPv6 socket: Address already in use
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >HINT: Is another postmaster already running on...retry.
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >LOG: could not bind IPv4 socket: Address already in use
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >HINT: Is another postmaster already running on...retry.
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >WARNING: could not create listen socket for "localhost"
Mar 02 18:09:26 localhost.localdomain pg_ctl[31266]: < 2016-03-02 18:09:26.862 CST >FATAL: could not create any TCP/IP sockets
Mar 02 18:09:27 localhost.localdomain systemd[1]: postgresql-9.4.service: control process exited, code=exited status=1
Mar 02 18:09:27 localhost.localdomain systemd[1]: Failed to start PostgreSQL 9.4 database server.
Mar 02 18:09:27 localhost.localdomain systemd[1]: Unit postgresql-9.4.service entered failed state.
Mar 02 18:09:27 localhost.localdomain systemd[1]: postgresql-9.4.service failed.
1 - install psmisc package to give a killall on Postgres
# yum install psmisc
2 - Run the kill
# killall -9 postgres
3 - Start / Stop
# systemctl stop postgresql- 9.4
# systemctl start postgresql- 9.4
4 - to check if the service is in execution,
# ps -aux | grep postgres