# \[Solved\] While executing: attempt to write a readonly database error

**URL:** <https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003>\
**Category:** Community Help\
**Tags:** v5-0\
**Created:** [May 20, 2020, 10:48pm UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003 "2020-05-20T22:48:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![murdocklawlesss](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/murdocklawlesss/32/13720_2.png) [@murdocklawlesss](https://discourse.pi-hole.net/u/murdocklawlesss)\
**Post date:** [May 20, 2020, 10:48pm UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/1 "2020-05-20T22:48:20Z")

</div>

while I tried to change status of whitelist entry I got this error.

my config;

ubuntu 18.04 5.3.0-1021-raspi2 (raspberry 4)  
apache 2.4.29  
php 7.4.6  
ownership of /etc/.pihole = root  
ownership of /etc/pihole = pihole  
ownership of /var/www/html/admin = www-data  
I also add user www-data to pihole group  
permission of pihole-FTL.db = 0644  
ownership of pihole-FTL.db = pihole all

I still can't change whitelist status?

---

<div class="post-metadata">

**Author:** ![hapollo](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/h/47e85d/32.png) [@hapollo](https://discourse.pi-hole.net/u/hapollo)\
**Post date:** [May 21, 2020, 12:20am UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/2 "2020-05-21T00:20:54Z")

</div>

Recently that happened to me with the v4.3.1. (haven't migrated to V5) Did all the things you tried and then simply copied the urls within adlists.list, deleted it, and recreated the file. You might need to do the same with your whitelist file.

usually happens with a file gets corrupted on the Rpi.

---

<div class="post-metadata">

**Author:** ![murdocklawlesss](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/murdocklawlesss/32/13720_2.png) [@murdocklawlesss](https://discourse.pi-hole.net/u/murdocklawlesss)\
**Post date:** [May 21, 2020, 10:47am UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/3 "2020-05-21T10:47:32Z")

</div>

make sure the ownerhips are correct in directory /etc/pihole. (you can find right ownership list @deHakkelaar post below.)

usermod -aG pihole www-data

reboot

this solved my problem. some of the files owned by root and that's why readonly error occured.

---

<div class="post-metadata">

**Author:** ![deHakkelaar](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dehakkelaar/32/674_2.png) [@deHakkelaar](https://discourse.pi-hole.net/u/deHakkelaar)\
**Post date:** [May 21, 2020, 10:21pm UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/4 "2020-05-21T22:21:43Z")

</div>

> [@murdocklawlesss](#):
>
> chown -R pihole:pihole /etc/pihole

That might not be a good move and cause other issues.  
Below proper ownership and permissions:

```auto
pi@ph5:~ $ stat -c "%U:%G %a %n" /etc/pihole/* | column -t
root:root 644 /etc/pihole/adlists.list
root:root 644 /etc/pihole/adlists.list.old
pihole:pihole 644 /etc/pihole/dhcp.leases
root:root 644 /etc/pihole/dns-servers.conf
root:root 644 /etc/pihole/ftlbranch
root:root 644 /etc/pihole/GitHubVersions
pihole:pihole 664 /etc/pihole/gravity.db
root:root 644 /etc/pihole/gravity.list
root:root 644 /etc/pihole/install.log
root:root 644 /etc/pihole/list.0.raw.githubusercontent.com.domains
root:root 644 /etc/pihole/list.1.mirror1.malwaredomains.com.domains
root:root 644 /etc/pihole/list.2.sysctl.org.domains
root:root 644 /etc/pihole/list.3.s3.amazonaws.com.domains
root:root 644 /etc/pihole/list.4.s3.amazonaws.com.domains
root:root 644 /etc/pihole/list.6.dehakkelaar.nl.domains
root:root 644 /etc/pihole/list.7.gitlab.com.domains
root:root 644 /etc/pihole/list.8.blocklist.cyberthreatcoalition.org.domains
root:root 644 /etc/pihole/localbranches
root:root 644 /etc/pihole/local.list
root:root 644 /etc/pihole/localversions
root:root 644 /etc/pihole/logrotate
pihole:pihole 644 /etc/pihole/macvendor.db
root:root 755 /etc/pihole/migration_backup
pihole:root 664 /etc/pihole/pihole-FTL.conf
pihole:pihole 644 /etc/pihole/pihole-FTL.db
root:root 644 /etc/pihole/setupVars.conf
root:root 644 /etc/pihole/setupVars.conf.update.bak

```

---

<div class="post-metadata">

**Author:** ![murdocklawlesss](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/murdocklawlesss/32/13720_2.png) [@murdocklawlesss](https://discourse.pi-hole.net/u/murdocklawlesss)\
**Post date:** [May 22, 2020, 10:24am UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/5 "2020-05-22T10:24:06Z")

</div>

yes you are probably right. I made ownership corrections like your list and it's still working. thanks for your warning.

---

<div class="post-metadata">

**Author:** ![SNNB5](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/snnb5/32/16584_2.png) [@SNNB5](https://discourse.pi-hole.net/u/SNNB5)\
**Post date:** [June 11, 2020, 5:41am UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/6 "2020-06-11T05:41:40Z")

</div>

Whoa hold on? My PiHole doesn't even have half of those!!

---

<div class="post-metadata">

**Author:** ![deHakkelaar](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dehakkelaar/32/674_2.png) [@deHakkelaar](https://discourse.pi-hole.net/u/deHakkelaar)\
**Post date:** [June 11, 2020, 7:08pm UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/7 "2020-06-11T19:08:10Z")

</div>

Thats bc things have moved on since version 4.  
The version 5 release stores lots of content, like the lists, in database files now.  
If you have a fresh clean V5 install, not an upgrade like mine, maybe you can update this thread with how ownership and privies should look like now ?

EDIT: Thinking, if you (or anyone) have an unaltered fresh install, output for below might be helpful for others:

`stat -c "sudo chown %U:%G %n" /etc/pihole/* | column -t`

`stat -c "sudo chmod %a %n" /etc/pihole/* | column -t`

If any deviates from the output, folks can just copy paste.

---

<div class="post-metadata">

**Author:** ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)\
**Post date:** [July 2, 2020, 7:08pm UTC](https://discourse.pi-hole.net/t/solved-while-executing-attempt-to-write-a-readonly-database-error/33003/8 "2020-07-02T19:08:14Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
