Pi-hole stops working after power outage or restart

Hi!

I posted this in another topic but figured I'd post it here, too. After one of the latest updates, that started to happen to me too. Interestingly, that thing happens only after a power outage, where the Raspberry Pi didn't get shut down properly – every time. With previous versions, that did not happen, even when power was unstable.

Naturally, when that happens, the http://pi.hole/ domain does not resolve too.

However, I do not have to reinstall; running 'pihole -r' and selecting "repair" fixes the problem. Yet, it's a bit of a pain to do that every time the power goes down, and it has been unstable here for the last couple of days. Moreover, even rebooting Raspbian properly bears the same consequences, requiring a repair ('pihole -r'). Perhaps some file does not get properly closed, causing corruption?

Thanks!

Run pihole -d after you reboot the pi and after you repair Pi-hole for two debug tokens.

Wish it was that simple for me. I lose power quite often at my home.Each time the pi-hole dies as a result.

When this happens I am not able to SSH to the pi (using putty.exe). But I can ping it. Is there still some way to run commands without being able SSH to the pi?

My workaround has been to get a UPS. That seemed to fix the dilemma. But today the power went out for longer than normal and I decided I'd better shut off the UPS as I didn't know how long the outage would last and didn't want to exhaust the UPS. I was crossing my fingers that maybe the UPS shut down would somehow be a more gentle power cut off than and it would save the pi-hole. Wrong!

My fix has been to make a backup image and do a restore from that backup image whenever the pi-hole dies. It's about a 30 minute recovery process to get everything back. But if there was a less drastic way to get it working again I'd sure like to know.

Maybe I just get second micro-SD card and with the backup image on it always ready to swap out when this happens. Seems so wrong to have to do this but at least that would minimize the down time.

Yes there is if hook up monitor/keyboard and login via console.
But if you lose connectivity to the Pi-Hole daemons as well as SSH, something is seriously wrong with your setup.
Is it a Raspberry Pi with Raspbian installed ?
Any other software installed that might cause issues ?
When in sh.t creek, does the Pi still have an IP ?

pi@noads:~ $ ip addr show eth0
    inet 10.0.0.2/24 brd 10.0.0.255 scope global eth0

Is the SSH daemon running ?

pi@noads:~ $ sudo service ssh status
   Active: active (running) since Mon 2017-05-29 19:58:35 CEST; 5 days ago

How is the filesystem mounted (is it ro=read only)?

pi@noads:~ $ mount | grep ' / '
/dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)

Below one will initiate a filesystem check at boot:

sudo touch /forcefsck
sudo reboot

I recently got a DMI to VGA adapter so I could have hooked it up!
But that thought never passed my mind. Ugh. That was my bad.

This morning after the outage it did have an IP. The same one as before. And I could ping that IP.

Below is from the pi-hole I restored from an image this morning. I don't think this is of much use as we would need to run these commands on the pi-hole after it's down from my next power outage?

pi@raspberrypi:~ $ ip addr show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:eb:45:64:fc brd ff:ff:ff:ff:ff:ff inet 192.168.0.14/24 brd 192.168.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::d351:d42e:1342:d6b5/64 scope link valid_lft forever preferred_lft forever
pi@raspberrypi:~ $ sudo service ssh status ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled) Active: active (running) since Sun 2017-03-05 17:17:06 EST; 2 months 29 days ago Main PID: 710 (sshd) CGroup: /system.slice/ssh.service ├─ 710 /usr/sbin/sshd -D ├─5360 sshd: pi [priv] ├─5366 sshd: pi@pts/0 ├─5368 -bash ├─5448 sudo service ssh status └─5452 systemctl status ssh.service Mar 05 17:17:06 raspberrypi systemd[1]: Started OpenBSD Secure Shell server. Mar 05 17:17:07 raspberrypi sshd[710]: Server listening on 0.0.0.0 port 22. Mar 05 17:17:07 raspberrypi sshd[710]: Server listening on :: port 22. Jun 03 21:19:52 raspberrypi sshd[5360]: Accepted password for pi from 192.168.0.11 port 57021 ssh2 Jun 03 21:19:52 raspberrypi sshd[5360]: pam_unix(sshd:session): session opened for user pi by (uid=0) Jun 03 21:25:52 raspberrypi sudo[5419]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/sbin...atus Jun 03 21:25:52 raspberrypi sudo[5419]: pam_unix(sudo:session): session opened for user root by pi(uid=0) Jun 03 21:25:52 raspberrypi sudo[5419]: pam_unix(sudo:session): session closed for user root Jun 03 21:26:13 raspberrypi sudo[5448]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/sbin...atus Jun 03 21:26:13 raspberrypi sudo[5448]: pam_unix(sudo:session): session opened for user root by pi(uid=0) Hint: Some lines were ellipsized, use -l to show in full.
pi@raspberrypi:~ $ mount | grep ' / ' /dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)

I am having a similar problem. When I loose power to my rasberry 3 pi B+ running:
pihole -v
Pi-hole version is v3.3.1 (Latest: v3.3.1)
AdminLTE version is v3.3 (Latest: v3.3)
FTL version is v3.0 (Latest: v3.0)

pi hole doesn't service requests and so computers on the network don't have internet access. However, if I simply go to the pi-hole admin page from another computer to the rasberry pi pi-hole starts running and the other computers have access to the internet. I really need this to come up cleanly after a power outage so others in the family don't need to deal with this.

Thanks for your help.

As in, simply pulling up the admin interface, "turns on" the DNS resolution for the networked computers (hibernate type of behavior on the raspberry)?

Does it happen only after a power outage or even after reboot?

Sorry, happens both on power outage and reboot.

what are the outputs of:

sudo systemctl status pihole-FTL.service

sudo systemctl status dnsmasq

nslookup flurry.com

sudo systemctl status lighttpd.service

AFTER a reboot/power failure (before pulling up the admin interface via web)

Here it is

pi@raspberrypi:~ $ sudo systemctl status pihole-FTL.service
● pihole-FTL.service - LSB: pihole-FTL daemon
   Loaded: loaded (/etc/init.d/pihole-FTL; generated; vendor preset: enabled)
   Active: active (exited) since Fri 2018-06-08 10:38:11 EDT; 3min 42s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 284 ExecStart=/etc/init.d/pihole-FTL start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/pihole-FTL.service

Jun 08 10:38:07 raspberrypi systemd[1]: Starting LSB: pihole-FTL daemon...
Jun 08 10:38:08 raspberrypi pihole-FTL[284]: Not running
Jun 08 10:38:08 raspberrypi pihole-FTL[284]: rm: cannot remove '/var/run/pihole/FTL.sock': No such file or directory
Jun 08 10:38:09 raspberrypi su[361]: Successful su for pihole by root
Jun 08 10:38:09 raspberrypi su[361]: + ??? root:pihole
Jun 08 10:38:09 raspberrypi su[361]: pam_unix(su:session): session opened for user pihole by (uid=0)
Jun 08 10:38:11 raspberrypi pihole-FTL[284]: FTL started!
Jun 08 10:38:11 raspberrypi systemd[1]: Started LSB: pihole-FTL daemon.

pi@raspberrypi:~ $

    pi@raspberrypi:~ $ sudo systemctl status dnsmasq
    ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
       Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
       Active: active (running) since Fri 2018-06-08 10:38:11 EDT; 3min 41s ago
      Process: 467 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
      Process: 450 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
      Process: 379 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
     Main PID: 463 (dnsmasq)
       CGroup: /system.slice/dnsmasq.service
               └─463 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg

    Jun 08 10:38:08 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
    Jun 08 10:38:11 raspberrypi dnsmasq[379]: dnsmasq: syntax check OK.
    Jun 08 10:38:11 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
    ...skipping...

Those outputs look fine.

What about:

nslookup flurry.com

sudo systemctl status lighttpd.service

See below. I did two nslookups back to back.

pi@raspberrypi:~ $ nslookup flurry.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: flurry.com
Address: 192.168.1.12

pi@raspberrypi:~ $ nslookup flurry.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: flurry.com
Address: 192.168.1.12

pi@raspberrypi:~ $ sudo systemctl status lighttpd.service
● lighttpd.service - Lighttpd Daemon
Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-08 13:15:27 EDT; 3min 40s ago
Process: 415 ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf (code=exited, status=0/SUCCESS)
Main PID: 550 (lighttpd)
CGroup: /system.slice/lighttpd.service
├─550 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
├─562 /usr/bin/php-cgi
├─659 /usr/bin/php-cgi
├─660 /usr/bin/php-cgi
├─661 /usr/bin/php-cgi
└─662 /usr/bin/php-cgi

Jun 08 13:15:22 raspberrypi systemd[1]: Starting Lighttpd Daemon...
Jun 08 13:15:27 raspberrypi lighttpd[415]: 2018-06-08 13:15:23: (server.c.1295) WARNING: unknown config-key: alias.url (ignor
Jun 08 13:15:27 raspberrypi systemd[1]: Started Lighttpd Daemon.
pi@raspberrypi:~ $
pi@raspberrypi:~ $
pi@raspberrypi:~ $ echo after refreshing http://192.168.1.12/admin/index.php?login
after refreshing http://192.168.1.12/admin/index.php?login
pi@raspberrypi:~ $ nslookup flurry.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: flurry.com
Address: 192.168.1.12

pi@raspberrypi:~ $ sudo systemctl status lighttpd.service
● lighttpd.service - Lighttpd Daemon
Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-08 13:15:27 EDT; 4min 51s ago
Process: 415 ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf (code=exited, status=0/SUCCESS)
Main PID: 550 (lighttpd)
CGroup: /system.slice/lighttpd.service
├─550 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
├─562 /usr/bin/php-cgi
├─659 /usr/bin/php-cgi
├─660 /usr/bin/php-cgi
├─661 /usr/bin/php-cgi
└─662 /usr/bin/php-cgi

Jun 08 13:15:22 raspberrypi systemd[1]: Starting Lighttpd Daemon...
Jun 08 13:15:27 raspberrypi lighttpd[415]: 2018-06-08 13:15:23: (server.c.1295) WARNING: unknown config-key: alias.url (ignor
Jun 08 13:15:27 raspberrypi systemd[1]: Started Lighttpd Daemon.
Jun 08 13:19:59 raspberrypi sudo[1046]: www-data : TTY=unknown ; PWD=/var/www/html/admin ; USER=root ; COMMAND=/usr/local/bin
Jun 08 13:19:59 raspberrypi sudo[1046]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jun 08 13:19:59 raspberrypi sudo[1046]: pam_unix(sudo:session): session closed for user root

Both nslookup commands returned the correct reply. That means that the DNS resolution was working, at least locally. (flurry.com is a known blocked domain and it was Pi-holed).

The Lighttpd Daemon on the other hand ... is behaving weirdly

Thanks for your help. Let me know, or anyone else, what I should do.

Thanks

Ramset,
Any suggestions on this issue?

Thanks for your help.

What about the same nslookup command on a client, after the raspberry came back online?

Form the above test you did locally, Pi-hole was working as expected (after power failure).

Is your raspberry hardwired into the router or ar you using the WiFi connection ?

It's a hardwired connection. Here is the output of ifconfig. Should wlan0 be down?

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::f56a:6de9:acb6:1811 prefixlen 64 scopeid 0x20
ether b8:27:eb:8f:e6:f2 txqueuelen 1000 (Ethernet)
RX packets 10942786 bytes 1286202824 (1.1 GiB)
RX errors 0 dropped 224948 overruns 0 frame 0
TX packets 4185446 bytes 449738352 (428.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 3388759 bytes 237819550 (226.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3388759 bytes 237819550 (226.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::ee61:e0b5:9dcf:465a prefixlen 64 scopeid 0x20
ether b8:27:eb:da:b3:a7 txqueuelen 1000 (Ethernet)
RX packets 6079409 bytes 601220673 (573.3 MiB)
RX errors 0 dropped 213739 overruns 0 frame 0
TX packets 9210 bytes 636651 (621.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Nslookup on my macbook after reboot but nothing else:
2017-Bens-MacBook-Pro:Downloads Ben$ nslookup flurry.com
;; connection timed out; no servers could be reached

VNC'd to rasberry pi 192.168.1.12
Nslookup on rasberry pi:
pi@raspberrypi:~ $ nslookup flurry.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: flurry.com
Address: 192.168.1.12

Still no internet on macbook

From macbook using chrome browser after connecting to raspberry pi http://192.168.1.12/admin/index.php

dns is working;

2017-Bens-MacBook-Pro:Downloads Ben$ nslookup flurry.com
Server: 192.168.1.12
Address: 192.168.1.12#53

Name: flurry.com
Address: 192.168.1.12

This does not seem to be related to the Pi-hole instance.
You were able to connect to the raspberry via VNC and the DNS worked when you queried the domain.

what's the response you get from your client when you run

nslookup flurry.com 192.168.1.12

After raspberry reboot, can you access the flurry page on a different device (maybe cell phone/tablet)?

Here are the results from my macbook pro

2017-Bens-MacBook-Pro:Downloads Ben$ echo before reboot of raspberry pi
before reboot of raspberry pi
2017-Bens-MacBook-Pro:Downloads Ben$ nslookup flurry.com 192.168.1.12
Server: 192.168.1.12
Address: 192.168.1.12#53

Name: flurry.com
Address: 192.168.1.12

2017-Bens-MacBook-Pro:Downloads Ben$ echo after raspberry pi reboot
after raspberry pi reboot
2017-Bens-MacBook-Pro:Downloads Ben$ nslookup flurry.com 192.168.1.12
;; connection timed out; no servers could be reached

After reboot on my iphone i could not reach yahoo.com.
Then I went to pi-hole admin page on my iphone
Then I was able to access yahoo.com from my iphone.

Does your router have DNS rebind protection ?