django.db.utils.OperationalError: unable to open database file

Suffering for a while from the same issue and I believe I have found a solution, finally!

sudo python manage.py runserver

and that did the trick for me.

My permissions were telling me that everything is how it should be. Regardless, I still had to type in sudo at the beginning of the command at the terminal.


Basically there are two answers, either user which running server don't have rights to open database file. You can try to fix this by:

sudo chown $(whoami):$(whoami) /path/to/dir/db/db.sqlite3

Or you don't have this file, you can create it by applying migrate command:

./manage.py migrate

Tags:

Django