When I run
python manage.py runserver
I get this error
File "/usr/local/lib/python2.7/dist-packages/Django-1.10.1-py2.7.egg/django/db/backends/sqlite3/base.py", line 209, in get_new_connection conn = Database.connect(**conn_params) django.db.utils.OperationalError: unable to open database file
my settings.py:
DATABASES = {
'default': dj_database_url.config(
default="sqlite:///{}".format(
os.path.join(BASE_DIR, 'db/db.sqlite3')
)
)
}
Just remove the first db in your settings.py file.
You have os.path.join(BASE_DIR, 'db/db.sqlite3')
if you remove the first db
, you'll have os.path.join(BASE_DIR, 'db.sqlite3')
Your database settings will be
DATABASES = {
'default': dj_database_url.config(
default="sqlite:///{}".format(
os.path.join(BASE_DIR, 'db.sqlite3')
)
)
}
I have similar problem.
You just run command with sudo
sudo python3 manage.py runserver
Enjoy!
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
I had the same problem, just solved it. Make sure www-data (or whatever daemon running your web server) has access to both the db.sqlite3 file, and also the path to it. So:
sudo chown :www-data <project_folder>/
sudo chown :www-data <project_folder>/db.sqlite3
sudo chmod 664 <project_folder>/db.sqlite3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With