// MySQL error reference

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
Error message
Unknown MySQL server host '%s' (%d)

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

  1. Check that the name resolves from the client machine, for example with nslookup db.example.com or ping db.example.com.

  2. Put only the host name in the host field and the port in the port field.

  3. From the host machine, a container's port is reached through 127.0.0.1 and the published port, not the service name.

Related errors

More connection and client errors

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.

// fewer errors, faster fixes

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.