Pi-Hole Alternative Port

Hi,

I suspect this isn't possible for various reasons and what I've read but I have to ask... is it possible to alter pi-hole's default ports? I'm trying to build a machine (RPi 5, 8Gb with 64Gb MicroSD, 2 x 2Tb SSD) with multiple installs on it and I had conflicts when I installed Apache (part of my Nextcloud install).

Perhaps I need to alter Apache's default port or, another option I read about, migrate Pi-Hole to Apache from lighttpd?

I don't have the greatest level of Linux experience but, FWIW, I really don't like Docker/Portainer so, while a solution, it's one I'd rather avoid.

Thanks

James

Are you using Pi-hole v5, or v6?

If v5, you can modify the port lighttpd is using via the ‘server.port’ configuration setting in /etc/lighttpd/lighttpd.conf.

I found this information via a search, and have not verified it myself. If you change the port, you will need to restart the lighttpd service for the change to take effect.

I know it can also be changed on v6, but not through lighttpd, as v6 does not use lighttpd.

Also note that there is an earlier post to this forum from back in 2021 indicating that lighttpd.conf could be overwritten by Pi-hole, and should not be changed (https://discourse.pi-hole.net/t/how-can-i-change-the-default-port-of-pihole-changing-lighttpd-conf-not-working/47560) . Not sure if this still applies, as I do not see the warning in the current lighttpd.conf file. I still use v5.

1 Like

If you will build a new machine with Pi-hole, you will install the current version: Pi-hole v6.

Pi-hole v6 doesn't use lighttpd. It has its own embedded web server.

You can change Pi-hole v6 web ports using this command:

# example using the default ports
sudo pihole-FTL -- config webserver.port '80,443s'

# example using alternative ports and "optional" flag
sudo pihole-FTL -- config webserver.port '8080o,8443os'

Notes:

  • add the o flag to make a port optional (the web server will start even if the port is in use by other service).
  • use the s flag to mark "secure" ports for HTTPS.

Yes, "pihole -v" says it's v6.

Tried that but I couldn't make it work, even edited what appeared to be a relevant section in the pihole.toml file, under "webserver" as I recall:

Changing it from port = "80o,443os,[::]:80o,[::]:443os" to port = "8080o,8443os[::]:8080o,[::]:8443os" commenting out the original line... it didn't make much (if any) difference but when I checked the file I found this: port = "8080o,8443os[::]:8080o,[::]:8443os" ### CHANGED, default = "80o,443os,[::]:80o,[::]:443os" and NO commented out line.

Very weird!

Even more weird, despite no success with any of the above, both services are now running simultaneously:

So I guess I just get on with the install now. Thanks for the help even if I don't really understand what was happening back there.

James

This is expected.

After any changes to the config file, Pi-hole v6 will read the file and read the changes. Then it will rewrite the file using the original format (every commented line will be removed and # CHANGED, default = ... will be added to all settings not using the default value).

Your image shows Apache and Pi-hole FTL service (this is the DNS service) running, but there is no way to know if the Pi-hole web server is running.

Please upload a debug log and post just the token URL that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

pihole -d

I also checked that I could reach the pages simultaneously but OK.

This? https://tricorder.pi-hole.net/8e1PzWEW/

James

The debug log shows your Pi-hole is configured to use ports 80 and 443, but Apache is using port 80 and Pi-hole using only port 443:

[✗] tcp:0.0.0.0:80 is in use by apache2 
[✓] tcp:0.0.0.0:443 is in use by pihole-FTL

This means you can access Pi-hole using https://, but you won't be able to access Pi-hole using http://.

If you want to access Pi-hole using http:// you can execute this command:

sudo pihole-FTL -- config webserver.port '8080o,443os'

And access Pi-hole using one of these URLs: