Status is offline but everything is working

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

[Pihole should be showing its status as active as everything is working correctly.
OS Dietpi/bullsye]

Actual Behaviour:

[pihole shows the status as offline]

Debug Token:

[https://tricorder.pi-hole.net/F0neLqHV/]

   2022-01-12 20:22:28: mod_fastcgi.c.487) FastCGI-stderr:PHP message: PHP Warning:  Executing sudo pihole status web failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 15

   2022-01-12 20:18:05: mod_fastcgi.c.487) FastCGI-stderr:PHP message: PHP Warning:  Executing sudo pihole restartdns reload-lists failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 15

Something is wrong here. The web interface failed to execute Pi-hole commands. Strangely, the relevant line of code is not at line 15.

Can you please run from the command line

pihole status web

Thanks for having a look.

pihole status web

53

The reply is correct, the issue must be with the web interface. Please try nuking it

sudo rm -rf /var/www/html/admin
sudo git clone https://github.com/pi-hole/AdminLTE.git /var/www/html/admin

I just nuked it the way you suggested. No change, it still says offline. I also did a reboot and pihole -up

Thanks for helping. Everything is working fine other than the status.

Can you provide a new debug token please?

No problem

https://tricorder.pi-hole.net/WcL89HmI/

Strange, it's the same issue again

   2022-01-13 16:34:11: mod_fastcgi.c.487) FastCGI-stderr:PHP message: PHP Warning:  Executing sudo pihole status web failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 15
   2022-01-13 16:34:11: mod_fastcgi.c.487) FastCGI-stderr:PHP message: PHP Warning:  Executing sudo pihole status web failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 15

Pining @MichaIng for DietPi assistance

Could it be an issue with permissions? I tried installing pihole via the curl method and also through the dietpi-software suite but either way still shows offline. I'm running pihole, unbound and pivpn together and it's working great :slight_smile:

Does this work?

sudo -u www-data sudo pihole status web

The sudoers file is installed correctly?`

cat /etc/sudoers.d/pihole

sudo -u www-data sudo pihole status web
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

cat /etc/sudoers.d/pihole
www-data ALL=NOPASSWD: /usr/local/bin/pihole

hi,
I had the same problem, and after lots of trial and error I found it was due to subtle syntax errors in the sudo setup , specifically missing spaces -

# **cat /etc/sudoers.d/pihole**
# Pi-hole: A black hole for Internet advertisements
# incorrect syntax here caused pihole admin pages to show Status=Offline , 14jan2022 robin
#www-data ALL=NOPASSWD: /usr/local/bin/pihole
www-data ALL = NOPASSWD : /usr/local/bin/pihole

After adding the missing spaces between ALL and = and NOPASSWD and the colon , the Pihole web status started showing 'Active' , and I no longer see 'PHP Warning: Executing sudo pihole version failed.' errors in the lighttpd error log
:slight_smile:

Interesting... the relevant code hasn't been touched in two years.

These spaces were never (and are not on all systems of all Debian versions I run and test) required.
EDIT: Also the official man page does not suggest a space after NOPASSWD: https://manpages.debian.org/sudoers#NOPASSWD

@hippytyre

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

That is an interesting error message, can you show:

ls -l /usr/bin/sudo

Sure:

-rwxr-xr-x 1 root root 135928 Feb 27 2021 /usr/bin/sudo

The SUID bit is indeed missing, that way sudo cannot work at all. Not sure how this can happen (it is natively shipped with the package, of course, and since we saw reports about this several years ago for fresh Raspbian images, the DietPi image script sets it as well), but here is how to resolve:

sudo chmod 4755 /usr/bin/sudo
2 Likes

That fixed the problem, thanks very much for spending time figuring that out.

Thanks guys :+1: