# Attempt to write a Read only database

**URL:** <https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744>\
**Category:** Deployment\
**Created:** [August 3, 2023, 10:43am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744 "2023-08-03T10:43:48Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 3, 2023, 10:43am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/1 "2023-08-03T10:43:48Z")

</div>

Hi Guys hope you are doing well,

Here I am Using Ubuntu to run my Django project (Mayan EDMS Open source project ) after running success fully and tried to login into the application and I am not get into home page because of DB is in the read only Mode, can any one help in this will be appreciated.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/f/f5f478faaa9a9c51e8ecfb36f28e1c48f5fc9f43.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 3, 2023, 11:23am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/2 "2023-08-03T11:23:52Z")

</div>

Are you using default django sqlite3? if yes, then  
You have to add writing rights to the directory in which your sqlite database is stored. So running `chmod -R u+w /path/` should help.

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 3, 2023, 12:53pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/3 "2023-08-03T12:53:54Z")

</div>

After running “chmod -R u+w mayan/media/db.sqlite3” still getting same error  
Any ways to get out of thiss?

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 3, 2023, 12:55pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/4 "2023-08-03T12:55:04Z")

</div>

can you share your folder structure tree

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 3, 2023, 12:58pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/5 "2023-08-03T12:58:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/1/15933aedc7aa2faaa6a09bfc9baf342f282e842e.png)

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 3, 2023, 1:00pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/6 "2023-08-03T13:00:36Z")

</div>

db.sqlite3 is in media folder have you specified this path, as it is not in root folder

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 3, 2023, 2:48pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/7 "2023-08-03T14:48:59Z")

</div>

You should be running the `chmod` command on the path `mayan/media` and not the file.

(Note: If you’re looking to deploy this to a production-style environment, you probably don’t want your database in that directory. The last thing you want to have happen is to have someone be able to craft a url that accesses your media directory and allows them to download that file.)

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 4, 2023, 5:01am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/8 "2023-08-04T05:01:24Z")

</div>

> [@shahidavalisyed](#):
>
> chmod -R u+w mayan/media/db.sqlite3”

I run those commands without file, still getting same  
any ways to get out of this?

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 4, 2023, 11:42am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/9 "2023-08-04T11:42:44Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/3/376030631d1c80d2298cb6b73b31e8771943a708.png)  
Can you plz check out and which permission should i change?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 4, 2023, 12:00pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/10 "2023-08-04T12:00:43Z")

</div>

What are the permissions on the `media` directory itself? (The directory, not the contents of the directory that you’re showing here.)

Also, how are you running your Django project?

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 4, 2023, 12:51pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/11 "2023-08-04T12:51:22Z")

</div>

I just made a “media” group and added to in that group except db.sqlite3 by it self

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 4, 2023, 1:06pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/12 "2023-08-04T13:06:16Z")

</div>

Unfortunately, that doesn’t answer my questions.

1. What are the permissions on the `media` directory itself? (What do you get if you do an `ls -l` if `mayan` is your current directory?)

2. How are you running your Django project? What commands or system configuration are you using for this? Is this intended to be a production deployment or is this your development environment?

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 7, 2023, 5:18am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/13 "2023-08-07T05:18:55Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/1/1e21e9bb78574ce9dadba8e570b0366e52fb4507.png)  
Please check Above media file has permission  
To run my django project “make runserver” and for development environment i am trying to run

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 7, 2023, 12:11pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/14 "2023-08-07T12:11:54Z")

</div>

As a development environment, then I’d say both the media directory and all its contents should have the same ownership as the rest of the files (`sayed:sayed`). There’s no need to start altering ownership and permissions until deployment.

---

<div class="post-metadata">

**Author:** ![shahidavalisyed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shahidavalisyed/32/15138_2.png) [@shahidavalisyed](https://forum.djangoproject.com/u/shahidavalisyed)\
**Post date:** [August 8, 2023, 5:14am UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/15 "2023-08-08T05:14:41Z")

</div>

Resolved Man Thank a lot Man 🙂

---

<div class="post-metadata">

**Author:** ![NafiGit](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nafigit/32/18950_2.png) [@NafiGit](https://forum.djangoproject.com/u/NafiGit)\
**Post date:** [February 4, 2024, 9:33pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/16 "2024-02-04T21:33:02Z")

</div>

What if it’s a prod db where should i house the db

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 4, 2024, 9:39pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/17 "2024-02-04T21:39:20Z")

</div>

Any directory that the UID being used for your Django process can access. It more important that its placement fits within your general guidelines for how your server is managed.

---

<div class="post-metadata">

**Author:** ![proxd15](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/proxd15/32/19812_2.png) [@proxd15](https://forum.djangoproject.com/u/proxd15)\
**Post date:** [March 11, 2024, 4:04pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/18 "2024-03-11T16:04:47Z")

</div>

![Screenshot (13)](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/6/c/6c2733cc3b8cfd233e30281b65c79bbf09e53b54.png)  
i am getting the same error , can somebody solve

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 11, 2024, 4:24pm UTC](https://forum.djangoproject.com/t/attempt-to-write-a-read-only-database/22744/19 "2024-03-11T16:24:42Z")

</div>

Welcome @proxd15 !

I suggest you open a new topic for this. This topic has been marked as solved and so your post is not likely going to attract attention.

When you do so, please don’t post images of code or text. Copy/paste the text into the body of your post, between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.

In addition to the directory listing here, also please show how you’re running your Django project, and post the complete error message being received in the logs from your application.

General note: You do _not_ want your project or database in the `/var/www` directory tree. Those files should remain outside the view of the web server and should only be accessible to the UID running the application. The _only_ files that should possibly be in `/var/www` would be your static and media files.
