Chapter 9 · 9.3
Website unreachable, 502 Bad Gateway or certificate error
The page doesn't load at all
- Does the name point to your VPS?
dig +short example.comshould return your IP address (see A and AAAA records in My Domains). - Are ports 80 and 443 open?
sudo ufw status(see A firewall with ufw (or nftables)). - Is the webserver running?
systemctl status caddyornginx, orsudo docker compose psin/srv/diensten. - Is anything listening?
sudo ss -tlnp | grep -E ':(80|443) '.
502 Bad Gateway
Your webserver is working, but it isn't getting a response from the app behind it.
- Is the app running?
sudo docker compose psandsudo docker compose logs --tail 50 <app>. - Are the name and port correct in the Caddyfile or in
proxy_pass? With Caddy in Docker, that's the service name, such asuptime-kuma:3001. With a webserver outside Docker, it's127.0.0.1with the published port. - Is the app still starting up? Some apps need a moment on first start. Wait a minute.
No certificate or a certificate error
- Check the log to see why the request fails:
sudo docker compose logs caddy,journalctl -u caddyor the output of certbot. - Let's Encrypt checks via port 80. If port 80 is closed, or the AAAA record points to an address where nothing is listening, the check fails.
- Have you tried many times in a row? Then you may have hit a Let's Encrypt limit. Wait an hour and fix the cause first.
- Is the certificate expiring without being renewed? Test with
sudo certbot renew --dry-run(nginx) or check the Caddy log.
Too many redirects
Does your browser say the page redirects too often? Often the app thinks it's running on http and redirects to https, after which the proxy redirects again. Check that your proxy sends X-Forwarded-Proto (see An app behind a reverse proxy) and that the address in the app starts with https://.
