The MySQL client cannot open a TCP/IP socket on the host system, blocking any network connection to the server.
MySQL Error 2004: CR_IPSOCK_ERROR happens when the client fails to open a TCP/IP socket, usually due to exhausted file descriptors, firewall limits, or insufficient privileges. Free system resources or adjust ulimit values to restore socket creation and reconnect to the MySQL server.
Can't create TCP/IP socket (%d)
Error 2004 appears when the MySQL client API calls socket() and the operating system refuses, so no network connection can begin.
The numeric placeholder in the message shows the errno value returned by the OS, letting you pinpoint the exact kernel-level problem.
The error surfaces during any MySQL connection attempt that uses TCP/IP: mysql CLI, client libraries, application pools, or GUI IDEs like Galaxy.
Local UNIX socket connections (for example, mysql --protocol=socket) bypass the issue because they do not need a TCP socket.
Without a valid socket your application cannot reach the database, causing service outages, failed deploys, and stalled CI pipelines.
Because the root cause is at the OS layer, repeated retries rarely help; proactive fixes are required.
Most cases trace back to resource exhaustion: the user or system hit the maximum number of open files or sockets (ulimit -n).
Kernel security tools (SELinux, AppArmor) or firewalls may block socket creation for the mysql process user.
On Windows, antivirus or low-level drivers can intercept winsock calls and return WSAENOBUFS (no buffer space).
First, read the errno in the parenthesis.
Errno 24 (EMFILE) means too many open files; errno 13 (EACCES) points to permissions.
Free resources by closing idle connections, killing stray processes, or increasing limits with ulimit -n 65535.
Restart the MySQL client or application to pick up the new limits, then reconnect.
High-traffic web servers often exhaust descriptors; use connection pooling and adjust max_connections.
Containers may inherit low default limits; set fs.file-max and nofile in Docker or Kubernetes manifests.
Systemd services require LimitNOFILE=65535 in the unit file to lift soft and hard caps.
Monitor open files and sockets with lsof and netstat to catch spikes early.
Define conservative connection pool sizes and enable wait_timeout cleanup on the server.
Automate ulimit tuning during provisioning via Ansible or cloud-init.
CR_CONNECTION_ERROR (2002) signals failure after a socket was created but could not connect.
CR_UNKNOWN_HOST (2005) appears when DNS resolution fails before any socket call.
ER_CON_COUNT_ERROR (1040) is server-side when max_connections is hit, not socket creation.
.
It is a client-side error generated before any packet reaches the MySQL server.
No. The socket must be created first. Raise OS limits or close idle handles.
Yes, if the client and server share the same host. Use --protocol=socket in the mysql CLI.
Galaxy’s connection manager surfaces OS limit warnings and auto-tunes ulimit values during session startup, preventing CR_IPSOCK_ERROR for desktop users.