PHP error (2): fsockopen(): unable to connect to 127.0.0.1:4711 (Connection refused)

The issue I am facing:
In settings I get the below error message:

There was a problem applying your settings.
Debugging information:
PHP error (2): fsockopen(): unable to connect to 127.0.0.1:4711 (Connection refused) in /var/www/html/admin/scripts/pi-hole/php/FTL.php:47

Details about my system:
Running on a raspberry pi with nothing else running on the device

What I have changed since installing Pi-hole:
Nothing changed. Was working fine, then I noticed ads on my devices. Tried to update gravity but this does not seem to work. Checked settings and saw that error. I'm a total newbie so don't really understand any of this! Appreciate some help.

Debug link is
https://tricorder.pi-hole.net/rHR8B6Df/

Apparently FTL crashed and it wasn't able to save the values from the web interface.

The debug log is not showing the entire crash info. Can you please run this command to upload the lines we need and post here the new token?

tail -n 100 /var/log/pihole-FTL.log | pihole tricorder

I'm running Pi-hole v5.25.2 and encountered occasional timeouts when accessing the FTL API. To mitigate this, I edited:

/var/www/html/admin/scripts/pi-hole/php/FTL.php

On line 47, I changed the default timeout in the fsockopen() function from 1.0 to 30 seconds:

// Open Internet socket connection
return @fsockopen($address, $port, $errno, $errstr, 30);

Everything still appears to work fine after the change, but I'd really appreciate it if someone could take a quick look and let me know:

  • Is this the right place and way to increase the timeout?
  • Are there any unintended consequences I should watch for (e.g., longer UI hangs if FTL is unresponsive)?
  • Would this be better handled elsewhere or made configurable?

Thanks in advance for your time and thoughts!

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