How to fix "unable to bind to port 53" error
This is an excerpt from https://www.bklynit.net/ubuntu-20-04-lts-docker-pihole/ hopefully the more specific title will help people find this more easily.
Problem
When trying to run pihole in a container on docker, you get:
Error starting userland proxy: listen tcp4 0.0.0.0:53: bind: address already in use
Cause
Another service is using port 53 already.
On Ubuntu this is systemd-resolved.
Fix
- Edit /etc/systemd/resolved.conf
- Uncomment the line with DNSStubListener and change yes to no. Save. Exit
- sudo systemctl restart systemd-resolved.service
- sudo rm /etc/resolve.conf
- sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Steps 1-3 stops systemd-resolved from binding to port 53. This prevents the system from doing DNS lookups. Steps 4-5 fixes that.