0

When I do gunicorn wsgi, I get PermissionError: [Errno 13] Permission denied: '/home/valachio/salvation/config/settings.py' (salvation is the name of the project).

I did most of my troubleshoting with this answer, which is the closest to my problem.

When I do ls -lash, the results for my wsgi and settings files look like this:

8.0K ---------- 1 valachio valachio 4.7K Jan  2 17:33 settings.py
0 -rw-rw-rw- 1 valachio valachio  385 Jan  2 13:56 wsgi.py

When I do ps aux | grep gunicorn, I get this:

valachio  3568  0.0  0.0 182924  1108 pts/0    S    11:35   0:00 grep --color=auto gunicorn

valachio is my username. It seems that the current user is the same as the owner of the settings.py file.

Why isn't this working? What can I try?

I am using the Linux 16.04 LTS sub-system on Windows 10.

Here is the full log after I run gunicorn wsgi -

[2018-01-03 11:28:54 -0500] [3561] [INFO] Starting gunicorn 19.7.1
[2018-01-03 11:28:54 -0500] [3561] [INFO] Listening at: http://127.0.0.1:8000 (3561)
[2018-01-03 11:28:54 -0500] [3561] [INFO] Using worker: sync
[2018-01-03 11:28:54 -0500] [3564] [INFO] Booting worker with pid: 3564
[2018-01-03 11:28:54 -0500] [3564] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
  File "/home/valachio/salvation/config/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/site-packages/django/conf/__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/valachio/.local/share/virtualenvs/salvation-uBeePQVz/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 661, in exec_module
  File "<frozen importlib._bootstrap_external>", line 766, in get_code
  File "<frozen importlib._bootstrap_external>", line 818, in get_data
PermissionError: [Errno 13] Permission denied: '/home/valachio/salvation/config/settings.py'
[2018-01-03 11:28:54 -0500] [3564] [INFO] Worker exiting (pid: 3564)
[2018-01-03 11:28:55 -0500] [3561] [INFO] Shutting down: Master
[2018-01-03 11:28:55 -0500] [3561] [INFO] Reason: Worker failed to boot.
Valachio
  • 1,025
  • 2
  • 18
  • 40
  • 3
    @Abe **Absolutely not!!** please don't *ever* advice *anyone* to use `chmod 777` on anything, for any purpose. OP, if you already tried this **seriously flawed advice,** you might want to remove the directory and restore from a backup if this is on a production system. – tripleee Jan 03 '18 at 16:49
  • In addition, you have not granted even yourself any permissions to access `seetings.py` - try `chmod 755 settings.py` to make it readable and executable for everyone, and writable just for yourself. (If it contains something secret, you want to be more restrictive; probably then use `700`.) – tripleee Jan 03 '18 at 17:13
  • chmod 755 worked for me. I wish I knew this existed. Thank you. You should post that as an answer so I can checkmark it. – Valachio Jan 03 '18 at 17:58
  • Please just accept the duplicate I nominated; the world doesn't really need yet another trivial duplicate of an extremely common newbie question. (For the record, accepting the duplicate simply marks this as "closed as a duplicate", and doesn't delete anything. There *may* come a time when that becomes a factor which contributes to the eventual removal of this question, but by then I guess neither you nor I nor anyone else will remember, let alone miss it.) – tripleee Jan 04 '18 at 16:06
  • Or if you can [edit] the question to also have the [tag:linux] tag, I have enough privileges in that tag to take it from there. This is properly a Unix/Linux problem more than an Ubuntu problem or a Gunicorn problem anyway. – tripleee Jan 04 '18 at 16:13
  • @tripleee I did both. Thanks for taking the time to keep the community organized! – Valachio Jan 04 '18 at 16:38

0 Answers0