Question

gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3

Posted December 15, 2019 1.4k views
DigitalOcean Spaces

Hi,

I followed this document and I’m hitting this error. Could you let me know what I’m missing? I tried several things the whole day and nothing has worked? I’m wondering whether these documented steps are tested well!?

$ sudo systemctl status gunicorn.socket
Failed to dump process list, ignoring: No such file or directory
● gunicorn.socket - gunicorn socket
   Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Sun 2019-12-15 05:15:27 UTC; 17s ago
   Listen: /home/xx/myproject/myapp/myapp.sock (Stream)
   CGroup: /system.slice/gunicorn.socket

Dec 15 05:15:27 ubuntu-s-01 systemd[1]: Listening on gunicorn socket.


$ sudo systemctl status gunicorn.service
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-12-15 04:22:54 UTC; 53min ago
 Main PID: 15788 (code=exited, status=1/FAILURE)

Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:     self.stop()
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:   File "/home/xx/myproject/xxenv/lib/python3.6/site-packages/gunicorn/arbi
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:     time.sleep(0.1)
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:   File "/home/xx/myproject/xxkenv/lib/python3.6/site-packages/gunicorn/arbi
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:     self.reap_workers()
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:   File "/home/xx/myproject/xxenv/lib/python3.6/site-packages/gunicorn/arbi
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Dec 15 04:22:54 ubuntu-s-01 gunicorn[15788]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Dec 15 04:22:54 ubuntu-s-01 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Dec 15 04:22:54 ubuntu-s-01 systemd[1]: gunicorn.service: Failed with result 'exit-code'.

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.

×
7 answers

Hello,

It looks like that the Gunicorn socket is missing, I would recommend following these steps here on how to create the socket and the service files:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04#creating-systemd-socket-and-service-files-for-gunicorn

And also if this is still not working, try following the steps here on how to test the socket activation here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04#testing-socket-activation

Hope that this helps!

Regards,
Bobby

by Justin Ellingwood
Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server...

Hello Bobby, thank you for your answer. Like I pointed in my question, I followed the same document and tried all the possible ways but there is no luck. I believe this is a bug in the current gunicorn software version. I’m not sure whether this has been verified in DO testing? I will point you whatever different settings that I used in gunicorn.socket and service files.

Hi Bobby,

Here is the files that I used with different lines. Please observe the commented lines too because I tried with them too.

cat /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket

[Socket]
#ListenStream=/run/gunicorn.sock
ListenStream=/home/xx/myproject/myapp/myapp.sock

[Install]
WantedBy=sockets.target

$ cat /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=xx
#User=root
Group=www-data
#WorkingDirectory=/home/xx/myproject/myapp/myapp
WorkingDirectory=/home/xx/myproject/myapp
ExecStart=/home/xx/myproject/xxenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/home/xx/myproject/myapp/myapp.sock \
          #--bind unix:/run/gunicorn.sock \
          myapp.wsgi:application

[Install]
WantedBy=sockets.target
$

Thanks

I changed the files as follows but the error is same.

cat /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock
#ListenStream=/home/xx/myproject/myapp/myapp.sock

[Install]
WantedBy=sockets.target

$ cat /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=xx
Group=www-data
WorkingDirectory=/home/xx/myproject/myapp/myapp
WorkingDirectory=/home/xx/myproject/myapp
ExecStart=/home/xx/myproject/xxenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          myapp.wsgi:application

[Install]
WantedBy=multi-user.target
$

Here is the gunicorn version that I’ve on my server.

pip show gunicorn
Name: gunicorn
Version: 20.0.2
Summary: WSGI HTTP Server for UNIX
Home-page: http://gunicorn.org

Hello DO, please let me know if you have any solution on this? I’m completely blocked without deploying my app on this server. I appreciate if DO can provide resolution asap!

Hello @bengaltiger, I was deploying my app and it rise the same error that you have. Did you know how to fix it? I’m completely blocked too.

It will be great if i have the solution.

Submit an Answer