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

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?

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.

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.

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

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

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

1 Like

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

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.

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