Error message: "Attempt to write a readonly database"

Installation went fine, and everything seems to work properly, except for the Group Management area. If I try to change anything relating to a group or client or domain, I get a message: “Error, something went wrong! While executing: attempt to write a readonly database.”

To make sure this wasn’t related to something I’d done to my install (I run an Nginx reverse proxy in front of it), I uninstalled Pihole completely, then reinstalled the latest stable version, then upgraded to the beta over the top. It still does it. Any ideas?

UPDATE: Actually, I also can’t add domains to the whitelist or to the blacklist. If I try, I get an error: “ Failure! Something went wrong, see output below: Error: attempt to write a readonly database, added 0 domains.” And nothing on my whitelist seems to have come over during the upgrade. But I can add custom DNS entries.

Same issue here. Cannot add to the whitelist. Same Error.

RPI4 - Dietpi - Recently upgraded to the beta.

Are you running the DietPi distribution of Pi-Hole, or the one from

The one from If it helps, I’m on a Pi 3B+ running Buster Lite.

Please generate a Pi-Hole debug log, upload when prompted and post the token here.

I ran it, but it’s saying There was an error uploading your debug log. I have a local copy.

Message me your local copy.

Just sent.

This is very likely a permission error somewhere.

@charlesjamesfox @BelowAverage Please also provide the output of the following

ls -lh /etc | grep pihole
ls -lh /etc/pihole/gravity.db
groups pihole

Do you use the lighttpd webserver installed by Pi-hole or do you run another webserver like apache2 or nginx?

I am using the DietPi installation of Pi-hole.

root@PiHole:~# ls -lh /etc | grep pihole
drwxrwxr-x 3 pihole pihole 4.0K Jan 19 13:09 pihole
root@PiHole:~# ls -lh /etc/pihole/gravity.db
-rw-rw-r-- 1 pihole pihole 99M Jan 19 12:35 /etc/pihole/gravity.db
root@PiHole:~# groups pihole
pihole : pihole

1 Like

I’m using Nginx. I chose not to install lighttpd during the install.

Results, as requested:

drwxrwxr-x 3 pihole pihole 4.0K Jan 19 15:10 pihole
-rw-rw-r-- 1 pihole pihole 9.6M Jan 19 14:10 /etc/pihole/gravity.db
pihole : pihole

Okay, so it seems you are both running non-standard configurations. Both times, your web server user is lacking group membership in the group pihole.

Not sure which user your web servers are running as (typical for lighttpd is www-data). Try to find out which is the correct web server user and add it to group pihole. Thereafter, restart your web server and try again. If this is not sufficient to communicate the new group membership (it should be), you might have to restart your system.

1 Like

That worked, albeit I still have a slight issue.

As you suggested, I added user www-data to group pi-hole and rebooted the Pi (rebooting the service didn’t do anything). Now, I can use the tools in Group Management.

I can also add domains to the whitelist. But . . . for some reason, the whitelist doesn’t show me the items that are on it, and even when it works, it gives me “Failure!” messages. If I try to add a new item that I know is not on the list, it says the following:

If I try to add an entry that I know is already on there, it gives me an error:

In all cases, it doesn’t show me what is on the list. The page looks like this:

Any ideas as to why? Thanks!

UPDATE: I cleared the cache in my browser, and everything showed up as expected. Thanks!
UPDATE 2: I said in an earlier post that the entries from my previous install had not migrated. This was incorrect. They just weren’t showing up until this issue was resolved.


This worked. I am using lighttpd. For those with a similar issue. I checked to see which users existed, as @DL6ER said the default user for lighttpd is www-data. I confimed by checking the /etc/passwd file that the user existed and added the user to the pihole group.

usermod -a -G pihole www-data

^^ will add the pihole group to the www-data user. You will need to use this command with an elevated account or with sudo.


Same problem here with dietpi but the solution seems to be working.


I have the same: Error, something went wrong!
While executing domainlist_by_group statement: attempt to write a readonly database

Running pihole on Ubuntu with Apache2
Did the user and group thing, but does not help.

$ groups pihole
pihole : pihole www-data

$ groups www-data
www-data : www-data pihole

$ ls -lh /etc | grep pihole
drwxrwxr-x 3 pihole pihole 4,0K Mär 7 21:11 pihole

$ ls -lh /etc/pihole/gravity.db
-rw-rw-r-- 1 pihole pihole 120M Mär 7 20:59 /etc/pihole/gravity.db


okay, got it fixed.
Reboot did the trick.

This still seems to be an issue when updating a fresh (2 Weeks ago) instance of Pihole to Beta5. Could this be fixed in the installer/updater?

If want to know the user that lighttpd runs under for your particular distro:

ps -o uid,user,gid,group,pid,cmd -C lighttpd

Eg. for Raspbian:

pi@noads:~ $ ps -o uid,user,gid,group,pid,cmd -C lighttpd
   33 www-data    33 www-data  1880 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf

Bumping this thread to note:

  • this issue still exists
  • adding the www-data user to the pihole group (usermod -a -G pihole www-data) then rebooting fixed the issue

I’m running Diet-Pi v6.28.0 and Pi-hole vDev release/v5.0, v4.3.5-459-g0fad979.

Pi-hole v4 was installed using dietpi-software command then upgraded via CLI.

1 Like