Gunicorn fails to start through systemd

Hey, I’m trying to get a django app that I’ve made work on the droplet, but I’m getting a really annoying issue with starting gunicorn through systemd

I was following this tutorial

and everything works as intented, till I test the socket activation

after typing in systemctl status gunicorn I get hit with this error message

● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2021-07-16 10:19:26 UTC; 25min ago
TriggeredBy: ● gunicorn.socket
    Process: 1769 ExecStart=/home/basic/project/projectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock myapp.wsgi:application (code=exited, stat>
   Main PID: 1769 (code=exited, status=217/USER)

Jul 16 10:19:26 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: Started gunicorn daemon.
Jul 16 10:19:26 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1769]: gunicorn.service: Failed to determine user credentials: No such process
Jul 16 10:19:26 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1769]: gunicorn.service: Failed at step USER spawning /home/basic/project/projectenv/bin/gunicorn: No such process
Jul 16 10:19:26 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: gunicorn.service: Main process exited, code=exited, status=217/USER
Jul 16 10:19:26 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: gunicorn.service: Failed with result 'exit-code'.

seeing the logfile with gunicorn --log-file=- myapp.wsgi:aplication gives me

[2021-07-16 10:47:20 +0000] [2260] [INFO] Starting gunicorn 20.1.0
[2021-07-16 10:47:20 +0000] [2260] [INFO] Listening at: (2260)
[2021-07-16 10:47:20 +0000] [2260] [INFO] Using worker: sync
[2021-07-16 10:47:20 +0000] [2262] [INFO] Booting worker with pid: 2262
[2021-07-16 10:47:20 +0000] [2262] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/", line 589, in spawn_worker
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/workers/", line 134, in init_process
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/workers/", line 146, in load_wsgi
    self.wsgi =
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/app/", line 67, in wsgi
    self.callable = self.load()
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/app/", line 58, in load
    return self.load_wsgiapp()
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/app/", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/basic/.local/lib/python3.8/site-packages/gunicorn/", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.8/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/basic/project/app/", line 12, in <module>
    from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
[2021-07-16 10:47:20 +0000] [2262] [INFO] Worker exiting (pid: 2262)
[2021-07-16 10:47:20 +0000] [2260] [INFO] Shutting down: Master
[2021-07-16 10:47:20 +0000] [2260] [INFO] Reason: Worker failed to boot.

Any ideas what might be wrong?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I’ve managed to find my issues. I was editing a gunicorn.service file in systemd, while I should have done it in systemd/system. Sloppy mistake