MySQL error 2005: Unknown MySQL server host
The client couldn't resolve the host name to an address. Check the spelling, DNS, and whether the name only resolves inside a VPN or a Docker network.
- Error number
2005- Name
CR_UNKNOWN_HOST- Category
- Connection and client
What it means
Before connecting, the client looks up the host name. 2005 means that lookup failed, so no connection was attempted. The number in brackets is the resolver's error code.
Common causes
- A typo in the host name, or a scheme or port pasted into the host field (
mysql://db:3306). - The name only resolves on a private network or VPN you're not connected to.
- A Docker Compose service name used from outside the Compose network, where it doesn't resolve.
- DNS problems on the client machine.
How to fix it
-
Check that the name resolves from the client machine, for example with
nslookup db.example.comorping db.example.com. -
Put only the host name in the host field and the port in the port field.
-
From the host machine, a container's port is reached through
127.0.0.1and the published port, not the service name.
Related errors
2003Can't connect to MySQL server on host2002Can't connect through socketORA-12154Oracle: TNS: could not resolve the connect identifier
More connection and client errors
2006MySQL server has gone away2013Lost connection to MySQL server during query2055Lost connection to MySQL server at stage2026SSL connection error2059Authentication plugin cannot be loaded2061Authentication plugin reported error1251Client doesn't support auth protocol3159Insecure transport prohibited
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.