Stumbled upon a case where the /etc/hosts file was deleted on the server, so caddy webserver did not know to resolve localhost locally:
root@localhost:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
25405529f45a openpanel/caddy-coraza "caddy run --config …" 21 hours ago Restarting (1) 12 seconds ago
docker logs -f caddy shows:
Error: loading initial config: loading new config: starting caddy administration endpoint: listen tcp: lookup localhost on 1.1.1.1:53: no such host
where tcp: lookup localhost on 1.1.1.1:53 indicates that caddy does not know that localhost should be local.
Checking /etc/hosts file confirmed there was no localhost entry, so just recreating it with:
127.0.0.1 localhost
::1 localhost
and restarting caddy resolved the issue.