Forums

Permission denied error while trying to run python manage.py migrate

Could any one please help me. I've tried all deemed solutions I found but the error still persist. Below is the error I'm getting

Traceback (most recent call last):
  File "/home/osenibabalola0/hbtelecom/manage.py", line 22, in <module>
    main()
  File "/home/osenibabalola0/hbtelecom/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/lib/python3.10/site- 
 packages/django/core/management/__init__.py", line 425, in 
execute_from_command_line
    utility.execute()
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/lib/python3.10/site
packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/lib/python3.10/site
packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/lib/python3.10/site
packages/django/core/management/base.py", line 412, in execute
self.check()
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/lib/python3.10/site
packages/django/core/management/base.py", line 438, in check
    all_issues = checks.run_checks(
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/core/checks/registry.py", 
line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=dat
abases)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/core/checks/caches.py", li
ne 63, in check_file_based_cache_is_absolute
    cache = caches[alias]
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/utils/connection.py", line
 62, in __getitem__
    conn = self.create_connection(alias)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/core/cache/__init__.py", l
ine 44, in create_connection
    return backend_cls(location, params)
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/core/cache/backends/fileba
sed.py", line 23, in __init__
    self._createdir()
  File "/home/osenibabalola0/.virtualenvs/mysite-virtualenv/l
ib/python3.10/site-packages/django/core/cache/backends/fileba
sed.py", line 121, in _createdir
    os.makedirs(self._dir, 0o700, exist_ok=True)
  File "/usr/local/lib/python3.10/os.py", line 215, in makedi
rs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/local/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/hbtelecom'

That appears to be trying to create some sort of cache directory. Make sure that, if you have configured a cache directory of some sort, that you're creating it in a directory where you have permissions.

Thanks @glenn. I had realized that too and that's what I've been trying to fix. So my issue is that I don't know how to check if if I have permission to write in that directory and give permission as needed?

You can check permissions by running ls -l /some/path command in a Bash console -- basically you should be able to write to all directories that you are the owner (your username is displayed in the 3 column of the output) and have write permissions ("w" on the 3 place in the 1 column) . It may look like:

$ ls -l /home/username
...
drwxrwxr-x 21 username registered_users    4096 Jun 16 15:12 foo

You should be able to write into any directory in your home directory (osenibabalola0) as well as to /tmp and /var/www.

Thank you pafk. I've already addressed the issue. The problem was not about not having write permission but how I referenced my cache location in settings.py file. It was rectified after I prepend /home/username to the cache location path that initially started with /hbtelecom