attempt to write a readonly database [Django 3.2.15 LTS]

Hi, my use ubuntu 22.04 from apache 2.

My error
OperationalError at /accounts/login/
attempt to write a readonly database

Used db.sqlite3


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

how to fix problem?

1 Like

Most likely cause is that the account being used to run your Django instance doesn’t have permissions to write to that file.

That database should be owned by that account. (“www-data” perhaps?)

That was my thought however when I changed permissions to 777 still got the same error.

It also needs to be able to write to the directory that the database resides in.

Thanks! I noticed that a couple hours latter. However strange part was that giving apache permissions alone did not recitfy the issue. While it is not necessary to use sqlite3 it would be nice. Django is pretty nice and fast development time for me but there are a few bugs to work out getting a robust deployment on my platform it seems. Had a few other issues as well, css files not getting allowed (got that working but was a PITA), then had to reinstall Pillow and a couple other python modules.