// MySQL error reference

MySQL error 2003: Can't connect to MySQL server on host

The client couldn't open a TCP connection to the host and port. The server is down, listens elsewhere, or a firewall is in the way.

Error number
2003
Name
CR_CONN_HOST_ERROR
Category
Connection and client
Error message
Can't connect to MySQL server on '%s:%u' (%d)

What it means

2003 is raised by the client when the TCP connection itself fails. The number in brackets is the operating-system error: (111) or (10061) on Windows means connection refused (nothing listening), (110) or (10060) means timed out (usually a firewall dropping packets), and (113) means no route to host.

The server never saw the login, so the password and grants don't matter yet.

Common causes

  • The server isn't running, or listens on another port than 3306.
  • The server only listens on 127.0.0.1 (bind_address), so remote connections are refused.
  • A firewall, security group or cloud network rule blocks port 3306.
  • Wrong host name or IP address in the connection settings.

How to fix it

  1. On the server, check that MySQL is running and which address and port it listens on.

    SHOW VARIABLES WHERE Variable_name IN ('bind_address', 'port', 'skip_networking');
  2. To accept remote connections, set bind_address = 0.0.0.0 (or the server's own IP) in the [mysqld] section of the configuration file and restart MySQL. Make sure an account exists for the remote host.

  3. Open the port in the server's firewall and any cloud security group, then test from the client machine, for example with nc -vz db.example.com 3306.

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.