Error message: "Attempt to write a readonly database"

Please contact DietPi for support with their distribution.

I will do that.

But I also note that Pi-hole v4 worked fine when I installed it on a fresh Diet-Pi today. It was only after upgrading to v5 that the saving issue appeared. I'm assuming there's something different about how the web server user attempts to write to a database in v5 vs how it wrote to local files in the /etc/pihole directory in v4 and that's what's causing the error to appear.

I suspect that once v5 is out of Beta, the Diet-Pi devs will incorporate it into their software installer. I suppose it's also completely possible that this issue goes away when v5 is able to be installed fresh.

Ping @MichaIng

Yes, the difference is that v4.0 calls sudo pihole ... which does all the changes whereas v5.0 has a completely re-engineered security concept directly interacting with the database without having a script in the middle of the operations. This elegantly solves a lot of things where we had to do validations before, e.g., against bash command exploitation.

Well, for this we have:

:thinking:

Many thanks for reporting. Yes this is a known issue with Pi-hole v5 on current DietPi and has been fixed already for the upcoming release.

If users choose to install the webserver manually, then it might even run as a different user, hence adding www-data to pihole group would not change something. Of course in very most cases it's www-data, but guessing too much and relying on it, is probably not he best solution. Instead a clear documentation about the needs might be better.

I opened a PR to add some more information about what is required to do manually, when skipping webserver install through Pi-hole installer: web server question enhancements by MichaIng ¡ Pull Request #3225 ¡ pi-hole/pi-hole ¡ GitHub

First it is asked whether to install the web interface, then it is asked whether to install webserver. Of course the second question does not make any sense if one already chose to not install the web interface, also practically in the script, choosing webserver has exactly zero effect when web interface is not chosen. The PR I linked also removes the webserver question when web interface was already deselected.

Now pihole does nothing, if you are not installing Lighttp.

The only things that are missing, and this only since Pi-hole v5 beta:

  • webserver permissions to access query database
  • PHP modules, i.e. php-intl, which is not part of most default PHP installs

Of course to have blocking page working as expected, the webserver needs to be configured to redirect 404 to it. And the admin web UI of course must be accessible by the webserver. But the blocking page is anyway not really recommended, at least not enabled by default and a performance penalty, and website access is somehow trivial.

IMO, if one already chooses to manually install and setup the webserver, I would skip really any related configure step. It can be wrong, it could even break things, if it does not match the manual system setup, or how it is/was intended.
PHP modules are btw a separate topic, since PHP has not really something to do with the webserver. But if a custom webserver setup is wanted, then a custom - probably custom compiled/package-less - PHP setup is present as well.

Got the same issue Stevejenkins Method works for me !!

Many Thanks

2 posts were split to a new topic: Read-only database

I have the same issue. I can not manage groups, clients and so on.
I did "usermod -a -G pihole www-data" then rebooted the device, but that does not fix the issue.
I am as well not sure which webserver is installed on my device. Since I installed this related to the installation description on Pi-hole v5.0 is here! – Pi-hole. But I started with Pi-Hole V4 and did the update to V5 yesterday. And after this I run into the issue.

What todo next?

That did it for me Since this has served as a reminder, a donation is on the way.
I appreciate your work and the help.
Thanks and Regards

2 Likes

A post was split to a new topic: Read-only database error

I had the same Problem and it worked for me: Unable to maintain black/white list in web interface ¡ Issue #1077 ¡ pi-hole/AdminLTE ¡ GitHub

sudo chmod g+w /etc/pihole

The Problem was caused by Updating.

6 Likes

Same problem here. Running pi-hole on Apache2 on RPi3B

Solved by doing:

sudo adduser www-data pihole
sudo systemctl restart apache2
2 Likes

I somehow ended up with the same problem and a Repair via pihole -r fixed the issue.

1 Like

THAT WORKED FOR ME THAAAAANK YOUUU

1 Like

Bingo, did the trick. Thanks!

1 Like