DNS resolution
A hostname identifies a service by name. DNS provides the records that help a client find it. A successful lookup does not prove that the service is reachable.
Ask for a specific record
dig example.com A
dig example.com AAAA
dig example.com MXAn A record contains an IPv4 address. An AAAA record contains an IPv6 address. MX records describe mail delivery destinations, not web servers.
Read the answer
Check the response status, record type and TTL. The TTL is a cache lifetime in seconds. Cached answers can remain in use after a record changes, until their lifetime expires.
dig +short example.com A
getent ahosts example.comThe first command gives a compact DNS answer. On Linux, getent follows the system's configured name-service lookup order, which may also include local host entries.
Separate name lookup from connectivity
If a lookup succeeds but a page fails, inspect the connection and TLS response separately. Repeatedly changing DNS will not fix a closed port or a service that is not listening.
Further reading: RFC 1034: Domain names.