netbox: gunicorn doesn't start on Ubuntu 16.04
I followed the docs and installed everything to the default directories. After installing gunicorn and supervisor, I get ‘502 Bad Gateway’ when I browse to the site.
When looking at ‘service gunicorn status’, I see:
● gunicorn.service
Loaded: loaded (/etc/init.d/gunicorn; bad; vendor preset: enabled)
Active: active (exited) since Wed 2016-06-29 20:41:33 MDT; 11min ago
Docs: man:systemd-sysv-generator(8)
Process: 1770 ExecStop=/etc/init.d/gunicorn stop (code=exited, status=0/SUC
Process: 1778 ExecStart=/etc/init.d/gunicorn start (code=exited, status=0/S
Jun 29 20:41:33 host systemd[1]: Starting gunicorn.service...
Jun 29 20:41:33 host gunicorn[1778]: * Starting Gunicorn workers
Jun 29 20:41:33 host gunicorn[1778]: *
Jun 29 20:41:33 host systemd[1]: Started gunicorn.service.
When I try to run the gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi command in the /etc/supervisor/conf.d/netbox.conf config file, from the /opt/netbox/netbox/ directory, I get the following:
[2016-06-29 20:51:34 +0000] [1890] [INFO] Starting gunicorn 19.4.5
[2016-06-29 20:51:34 +0000] [1890] [INFO] Listening at: http://127.0.0.1:8001 (1890)
[2016-06-29 20:51:34 +0000] [1890] [INFO] Using worker: sync
[2016-06-29 20:51:34 +0000] [1890] [INFO] Unhandled exception in main loop:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 180, in run
self.manage_workers()
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 482, in manage_workers
self.spawn_workers()
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 548, in spawn_workers
self.spawn_worker()
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 502, in spawn_worker
self.cfg, self.log)
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 55, in __init__
self.tmp = WorkerTmp(cfg)
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/workertmp.py", line 26, in __init__
util.chown(name, cfg.uid, cfg.gid)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 172, in chown
os.chown(path, uid, gid)
OSError: [Errno 1] Operation not permitted: '/tmp/wgunicorn-V9j_ep'
if I run as sudo, I get this:
[2016-06-29 20:52:26 +0000] [1929] [INFO] Starting gunicorn 19.4.5
[2016-06-29 20:52:26 +0000] [1929] [INFO] Listening at: http://127.0.0.1:8001 (1929)
[2016-06-29 20:52:26 +0000] [1929] [INFO] Using worker: sync
[2016-06-29 20:52:26 +0000] [1934] [INFO] Booting worker with pid: 1934
[2016-06-29 20:52:26 +0000] [1934] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 366, in import_app
__import__(module)
File "/opt/netbox/netbox/netbox/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 366, in import_app
__import__(module)
File "/opt/netbox/netbox/netbox/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
[2016-06-29 20:52:26 +0000] [1934] [INFO] Worker exiting (pid: 1934)
[2016-06-29 20:52:26 +0000] [1935] [INFO] Booting worker with pid: 1935
[2016-06-29 20:52:26 +0000] [1935] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 366, in import_app
__import__(module)
File "/opt/netbox/netbox/netbox/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 366, in import_app
__import__(module)
File "/opt/netbox/netbox/netbox/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
[2016-06-29 20:52:26 +0000] [1935] [INFO] Worker exiting (pid: 1935)
[2016-06-29 20:52:26 +0000] [1929] [INFO] Shutting down: Master
[2016-06-29 20:52:26 +0000] [1929] [INFO] Reason: Worker failed to boot.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (1 by maintainers)
I fixed this with the link from @therealjoshuad and running ALL of my “pip” commands as “sudo -H”
I rebuild a new VM with Ubuntu 16.04 and ran through the documentation again. I am having the same exact issue. Anyone else seeing this?
I ran into this issue as well from a fresh Ubuntu 16.04.2 install and using python 3. Gunicorn is trying to run from python2.7
Installing gunicorn (and uwsgi, maybe not required) for python3 fixed the issue for me. Run:
sudo -H pip3 install gunicorn uwsgi@LociNetworks thanks I found the mistake. I install it package at OS level. I remove the package and reinstall while activating the virtual environment I created. Now its fine.
But now I am not able to find the following file at the following path sudo nano /etc/systemd/system/gunicorn.service
setting up django on Linux I am following the steps from the below location, https://gist.github.com/ganmedia/afbada8ff6ff1733e27f7fd818eb34fd