The site can't be visited through domain name

I am running a website on my server, and I meet an issue when I am using Caddy

  1. If I access through IP, I will get the following information
404 Site IP is not served on this interface

I think this means Caddy works

  1. If I access through IP and port, I can visit the website, also works well.

  2. If I access through the domain name, I will get error

The connection has timed out

The server at domain name is taking too long to respond.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

my Caddyfile is

domainname.com {
 proxy / ip:port {
    header_upstream Host {host}
    header_upstream X-Real-IP {remote}
    header_upstream X-Forwarded-For {remote}
    header_upstream X-Forwarded-Proto {scheme}
  }
 log /var/log/caddy.log
 gzip
}

Any ideas? Thank you so much.

Hi @hzb,

Sounds like DNS isn’t resolving your domain name to the same IP address you use to access Caddy. Double check your DNS records are accurate.