Django can't get access to sqlite3 database

April 6, 2016 2.4k views
Nginx Django Let's Encrypt One-Click Install Apps Security Ubuntu

I am currently running a server instance of the one-click install option for Django Ubuntu 14.04.

This server is running a Django app using NGINX, sqlite3, and gunicorn.

I set up letsencrypt properly and it is used to serve my website with ssl.

I deleted all of the files in /home/django/dango_project/ and replaced them with my own.

When I load my website, everything works fine, except for my admin site.

I am able to log in to the admin site when I run the django_project locally, but it isn't working when the project is in production at my website.

You can verify that my db.sqlite3 file exists and contains posts by going to

With debug disabled, my website gives a Server Error (500) after I log in to my admin site.

With debug enabled, my website gives OperationalError at /admin/
attempt to write a readonly database
after logging into the admin site.

I have been trying to get into my admin site for nearly 5 hours now, no google searches are helping.

I appreciate any help in advance!

4 Answers

Where you able to figure anything out? I just ran into the same problem.

open puTTy
once you link the ip address and login
cd into file location ie
cd /home/django/django_project/
then enter

chown django:django db.sqlite3

Here my solution:

root@fiq:/home/django/django_project# chmod 777 db.sqlite3

root@fiq:/home/django/django_project# cd ..

root@fiq:/home/django# chmod 777 *

Go to <your_website/admin> put username and password.. That's it.

  • Hello,
    I appreciate your help
    I tried the above but I still receive a Server Error (500)

    • Try this.

      nano /etc/init/gunicorn.conf,

      change to :

      '# If the process quits unexpectadly trigger a respawn

      *change to

      www-data django
      www-data django

      Hope this can help.

      • Hi btlychee,
        Thanks for the follow up.
        I have the gunicorn.conf file open, and I see

        # If the process quits unexpectadly trigger a respawn

        But I don't see

        www-data django
        www-data django

        In the file. You told me to "change to" two things, I'm not sure I understand what to change. Could you please be more specific as to what I should change?

        Again, I appreciate the help

The solution I found is very simple: you just need to add writing permission to the users of the database. Go to the folder of you db.sqlite3 and run chmod a+w db.sqlite3 to add writing permission for all users. Then run service gunicorn restart if the changes do not take effect. Worked for me.

Have another answer? Share your knowledge.