OperationalError at /admin/login/ attempt to write a readonly database

I’m using gunicorn + nginx in my project, I can’t login to the admin panel. It doesn’t work when I give the command “python manage.py runserver” in the virtual environment. What can I do?

I think the error message is fairly clear here. Whatever account you are using in your DATABASES definition in your project settings doesn’t have permissions to write to your database. So the fix is to either adjust the permissions on the database or change the user being used.

the source of the problem is exactly i tried to give these permissions i gave chomd 777 it didn’t work how can i solve it i don’t know what to do

What database are you using?

using sqlite3 database

Ok, we’re going to need to know a lot more about your deployment environment.

Lets start with these:

  • What does your DATABASES setting look like?
  • What account is gunicorn running as?
  • What operating system is this running on?
  • Are you running this on your own server or in a cloud-provided service?
  • Have you done any other successful deployments to this environment?
  1. database settings:
    image
  2. working in gunicorn virtual env
  3. aws
  4. ubuntu 18.08
  5. only this

That refers to the Python environment in which gunicorn runs - I’m more interest in knowing about the gunicorn process. How is it started, and what account is it running as?

  • sudo systemctl start gunicorn.socket
  • sudo systemctl enable gunicorn.socket
    starting gunicorn with running ubuntu user
    image

Ok, verify that the ubuntu user has ‘rwx’ permissions to the parent directory of that file.

Also, somewhere in /usr/lib/systemd, you should find a file named gunicorn.socket (or possibly gunicorn.socket.service, but probably not). That file contains the definition of the service. Within that file is an ExecStart command which specifies the actual command being run.
That command probably references some configuration file for gunicorn.
Either the command line itself or that configuration file should specify what account is actually running gunicorn.

rwxrxwrwx 1
and root privileges granted. I checked the place where you said there is no problem in the working of gunicorn. still no result :frowning:

I’m not saying that there is a problem with running gunicorn.
The outstanding question is what is the UID that the gunicorn process is running as. For example, what is the output of sudo ps -AF | grep gunicorn? (I don’t use gunicorn, so I’m not 100% sure that that would be the process name - but it’s a place to start.)