Ubuntu Host Preparation for Pi-hole (Port 53 Conflict Fix)
1. The Issue: Port 53 Conflict
By default, Ubuntu runs systemd-resolved, which acts as a local DNS stub listener on Port 53. Pi-hole also requires Port 53 to function as a DNS server. If systemd-resolved is not modified, the Pi-hole container will fail to start with an "address already in use" error.
2. The Fix: Steps to Release Port 53
Step 1: Disable the DNS Stub Listener
- Open the resolved configuration file:
sudo nano /etc/systemd/resolved.conf
- Locate the line
#DNSStubListener=yes. - Change it to:
DNSStubListener=no
- Save and exit (
Ctrl+O,Enter,Ctrl+X).
Step 2: Fix Local DNS Resolution
Since the stub listener is disabled, the default 127.0.0.53 DNS entry will no longer work. Point the system to the upstream DNS file instead so the host maintains internet connectivity.
- Remove the existing symlink:
sudo rm /etc/resolv.conf
- Create a new symlink to the actual resolv file:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Step 3: Reload and Restart Services
Apply the changes and reload the daemon to clear any configuration warnings.
sudo systemctl daemon-reload sudo systemctl restart systemd-resolved
Verification
Check if Port 53 is free (output should be empty or not show systemd-resolved):
sudo lsof -i :53
