Installing Pi-hole or AdGuard Home on Ubuntu often fails with an error that port 53 is already in use. The culprit is the stub resolver of systemd-resolved on 127.0.0.53.
Switch the stub off in a drop-in:
sudo mkdir -p /etc/systemd/resolved.conf.d
sudo tee /etc/systemd/resolved.conf.d/no-stub.conf <<'EOF'
[Resolve]
DNSStubListener=no
EOF
sudo systemctl restart systemd-resolved
The resolved.conf man page says the default is yes, listening on 127.0.0.53 and 127.0.0.54, port 53, over UDP and TCP; no disables it. After the restart, sudo ss -lunp 'sport = :53' should show nothing until Pi-hole starts.
There is a catch in /etc/resolv.conf. On Ubuntu it is usually a link to stub-resolv.conf, which points at the stub you just turned off, so the box itself can no longer resolve names. Point it at the file with the real upstream servers instead:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
I would do that before anything else, or package installs on the box may start failing. Once Pi-hole runs, you can also put DNS=127.0.0.1 in resolved’s config so the server uses its own Pi-hole.
Further reading: resolved.conf man page, systemd-resolved.service man page