Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

450
Views
OperationalError at / unable to open database file Appears Sporadically

I am getting the following error when I try to run a Django site in production:

OperationalError at / unable to open database file

The strangest part is that it worked for a few page reloads and even clicks on different navigation links. Then, it worked every other time or so. At the end, it stopped working all together. This behavior is very puzzling.

Here is the relevant piece from settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

I have done chmod 777 db.sqlite as well as chmod o+w . within the directory where db.sqlite3 is located. It did not help.

How could I fix this? I am using a basic EC2 instance with Linux and Apache 2.4

Edit:

I have just duplicated the entire directory of the project using cp project project1 and then did mv project1 project. This made the site work for a few clicks, but then the error started creeping in again. Could this be a server issue?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I fixed it by running the following two commands from within the directory where the DB file was stored:

sudo chown apache:www db.sqlite3

sudo chown apache:www .

This did it for me for AWS EC2 with Amazon Linux (CentOS)

over 4 years ago · Santiago Trujillo Report

0

You set the name of your DB to the full path. Don't do this. Just say 'NAME': 'db.sqlite3'

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!