MySQL client error 2011 (CR_TCP_CONNECTION) means the client library failed to open a TCP/IP socket to the MySQL server.
MySQL Error 2011: CR_TCP_CONNECTION occurs when the client cannot open a TCP/IP socket to the MySQL server. Check network reachability, host, port, and firewall rules, then retry the connection.
%s via TCP/IP
Error 2011 is raised by the MySQL client library when it cannot establish a TCP/IP socket to the target MySQL server. The error text usually appears as “hostname via TCP/IP.” The issue is purely connection-level and happens before authentication, so SQL syntax is not involved.
This error can surface in the mysql CLI, application drivers, or GUI tools. It blocks all database operations because no session can be opened.
Fixing it quickly is critical for uptime and data accessibility.
Network reachability problems are the leading cause. If the client host cannot reach the server on the configured IP and port, the TCP handshake fails and MySQL returns CR_TCP_CONNECTION.
Incorrect connection parameters such as wrong hostname, port, or protocol can also trigger the error.
Firewalls, VPN misconfiguration, and host-based access controls routinely block traffic and surface as error 2011.
Resource exhaustion on the client or server side can block new sockets. Hitting the open-file limit, running out of ephemeral ports, or kernel-level connection tracking limits will all prevent a TCP socket from opening.
Start by validating the hostname and port. Use ping and telnet or nc to ensure the server is reachable.
Correct any typos in the connection string or DSN.
If the host is reachable, inspect firewall rules on the client, network, and server. Allow inbound traffic to the MySQL port (default 3306) and verify security groups or iptables rules.
Check server status. If mysqld is not listening on the expected port, start or restart the service. Confirm with netstat -tlnp or ss -ltn.
Investigate resource limits.
Raise ulimit -n on Linux if the open-file count is exhausted, and review net.ipv4.tcp_tw_reuse or nf_conntrack_max for high-traffic environments.
Local development – When Docker containers map MySQL to a non-default port, update the connection string to match the exposed port.
Cloud deployments – Security groups may block 3306. Add an allow rule for the client subnet or use an SSH tunnel.
High-load servers – Many short-lived connections exhaust the TIME_WAIT bucket.
Enable connection pooling or adjust the TCP stack settings.
Use connection pooling to minimize socket churn and lower the chance of hitting OS limits. Monitor open connections and file descriptors in Prometheus or similar tools.
Harden firewalls with least-privilege rules but document every allowed source. Automate configuration with IaC to prevent accidental blocks.
Store connection parameters in environment variables or a secrets manager to avoid typos.
Automate testing of connectivity in CI pipelines.
CR_CONNECTION_ERROR (2002) – MySQL can’t connect through any protocol. Similar troubleshooting steps apply but includes Unix-socket checks.
CR_SERVER_GONE_ERROR (2006) – The server closed an established connection. Network stability and wait_timeout tuning resolve this.
CR_SERVER_LOST (2013) – Connection lost mid-query. Investigate timeouts, packet-size limits, and proxy resets.
.
No. It often indicates a network or firewall issue even when mysqld is running.
No. The error occurs before authentication. You must resolve network or OS-level problems first.
Incorrect SSL parameters can block the handshake, but the server must still be reachable. Most SSL errors appear after TCP connects.
Galaxy stores validated connection profiles and pings the server before query execution, alerting you early if TCP connectivity fails.