DBAtlas · Database operations atlas

7 HostNotFound: Could not find host

MongoDB

What does it mean?

MongoDB could not resolve/find a host name it tried to connect to. The driver or a replica set member cannot reach the specified host, so the connection cannot be established.

Why does it happen?

DNS resolution failure, a wrong/stale host name in the connection string, replica set member host names (rs.conf) that the client cannot resolve, or a network/access problem. In container environments, internal host names that cannot be resolved from outside are the typical cause.

How to fix it

Verify that the host name is correct and resolvable (test DNS with ping/nslookup). Update the hosts in the connection string. Make sure replica set member names are resolvable by both clients and members; if needed, update the host names in rs.conf() to reachable FQDNs/IPs. If you use SRV (mongodb+srv), check the DNS SRV records.

Open in DBAtlas →

More from this engine