Gunicorn is not starting due to cannot open `/run/gunicorn.sock' error

November 11, 2019 107 views
DigitalOcean Articles

Hi,

I went through this document

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

and able to complete till this step Testing Socket Activation section and the following result is returned.

$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-11-11 00:37:48 UTC; 1h 7min ago
 Main PID: 23040 (code=exited, status=3)

Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: ModuleNotFoundError: No module named '**myproject'**
Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: [2019-11-11 00:37:48 +0000] [23064] [INFO] Worker exiting (pid: 23064)
Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: [2019-11-11 00:37:48 +0000] [23040] [INFO] Shutting down: Master
Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: [2019-11-11 00:37:48 +0000] [23040] [INFO] Reason: Worker failed to boot.
Nov 11 00:37:48 xxxxxxxxx systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Nov 11 00:37:48 xxxxxxxxx systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Nov 11 00:37:48 xxxxxxxxx systemd[1]: gunicorn.service: Start request repeated too quickly.
Nov 11 00:37:48 xxxxxxxxx systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Nov 11 00:37:48 xxxxxxxxx systemd[1]: Failed to start gunicorn daemon.

Since I noticed myproject in the above error I deleted

/run/gunicorn.sock file by running sudo rm /run/gunicorn.sock
and then corrected project name in gunicorn.service file and repeated the same steps. I see new error this time
$ file /run/gunicorn.sock
/run/gunicorn.sock: cannot open `/run/gunicorn.sock' (No such file or directory)

Does it mean that I should never delete the socket file to generate new file? Please let me know if there is a remedy for this instead of rebuilding the whole server again?

Thanks

1 Answer

I was able to avoid this error $ file /run/gunicorn.sock
/run/gunicorn.sock: cannot open `/run/gunicorn.sock' (No such file or directory)
by restarting, renabling gunicorn.socket but starting gunicorn still returned the same error.
snippet > Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Nov 11 00:37:48 xxxxxxxxx gunicorn[23040]: ModuleNotFoundError: No module named '**myproject'**

Thanks

Have another answer? Share your knowledge.