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
Related
gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=root
WorkingDirectory=/var/www/botproject/
ExecStart=gunicorn --workers 5 --bind unix:/run/gunicorn.sock botproject.wsgi:application
[Install]
WantedBy=multi-user.target
/var/www/botproject/ - project folder
systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2022-07-09 21:28:04 UTC; 3s ago
Process: 83314 ExecStart=/usr/local/bin/gunicorn --workers 5 --bind unix:/run/gunicorn.sock botproject.wsgi:application > Main PID: 83314 (code=exited, status=200/CHDIR)
Jul 09 21:28:04 server.domain.com systemd[1]: Started gunicorn daemon.
Jul 09 21:28:04 server.domain.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIR
Jul 09 21:28:04 server.domain.com systemd[1]: gunicorn.service: Failed with result 'exit-code'.
I can't figure out what is causing the 200/CHDIR error
I would start debugging by trying to run the ExecStart command manually, and see if that works (or what error you get):
$ cd /var/www/botproject/
$ sudo gunicorn --workers 5 --bind unix:/run/gunicorn.sock botproject.wsgi:application
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.
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'm trying to run my django project on gunicorn socket as service. But it fails to start; Can anybody help me with this?
I tried by following this link: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
I'm also using virtualenvwrapper to manage my virtualenvs.
Here is my configuration files:
/etc/systemd/system/gunicorn.socket:
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=mohsen
Group=www-data
WorkingDirectory=/home/mohsen/Desktop/SummerCampDocs/carpooling/carpooling
ExecStart=/home/mohsen/.virtualenvs/carpooling/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock carpooling.wsgi:application
[Install]
WantedBy=multi-user.target
By running this commands:
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
sudo systemctl status gunicorn
I get the following message:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-08-28 12:38:18 +0430; 33min ago
Process: 14000 ExecStart=/home/mohsen/.virtualenvs/carpooling/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock carpooling.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 14000 (code=exited, status=1/FAILURE)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: self.stop()
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: time.sleep(0.1)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: self.reap_workers()
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Aug 28 12:38:18 mohsen-ThinkPad-T490 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Aug 28 12:38:18 mohsen-ThinkPad-T490 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
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.