#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Decoding MySQL Error #2002 on Ubuntu

When you attempt to access phpMyAdmin from a local development environment and encounter error #2002, the message is blunt: "The server is not responding (or the local MySQL server's socket is not correctly configured)." This specific error usually points to a disconnect between your application layer (phpMyAdmin) and the database engine itself, rather than a generic network outage.

The root cause often lies in how MySQL handles local connections versus remote ones on Linux systems like Ubuntu. By default, modern versions of MySQL/MariaDB prioritize socket files over TCP/IP ports for local communication. When phpMyAdmin tries to connect, it attempts to reach the database via the Unix socket file defined in your configuration. If that path is missing, incorrect, or if the user permissions do not align, the connection fails immediately with this error code.

It is a common misconception that checking open ports is the primary diagnostic step here. Running pgrep mysql confirms the process is active, but as you noted, seeing that two ports are open does not guarantee local connectivity. Often, these ports are bound for external traffic or specific internal replication channels, while the local socket remains the actual handshake mechanism. Relying solely on port availability can lead to chasing network flags instead of fixing the underlying configuration.

To resolve this, you must inspect the MySQL server's socket configuration. On Ubuntu, the default socket location is typically /var/run/mysqld/mysqld.sock, though it can vary based on how the service was installed or configured. You can verify the current socket path by executing:

mysqladmin variables | grep socket

If the output shows a valid path but phpMyAdmin still fails, check if that directory exists and is owned by the correct user. The mysqld process usually runs as the mysql user. If the socket file is missing entirely, restarting the service might be necessary:

sudo systemctl restart mysql

However, a restart alone won't fix permission issues. You must ensure the directory containing the socket belongs to the MySQL user and has the correct group permissions (often mysql:mysql). A mismatch here prevents the web server process from reading the socket file, even if the database is running perfectly.

Another frequent pitfall involves conflicting configurations. If you have previously forced MySQL to listen on a specific TCP port for local connections, you might be overriding the default behavior without realizing it. Check /etc/mysql/mariadb.conf.d/ or /etc/mysql/mysql.conf.d/ for any bind-address directives that restrict local access. Ensure that bind-address = 127.0.0.1 is set if you intend to use TCP, but remember that phpMyAdmin often expects the socket unless explicitly configured otherwise.

If you are using a Dockerized environment or a specific stack like Laravel, the issue might be even more subtle. In containerized setups, the application inside the container cannot directly access the host's socket file. You must ensure the container is mounted with the correct socket path or that MySQL is running in TCP mode within the container with the proper network bridge configured.

For developers managing production environments where stability is key, relying on socket files is generally safer as it prevents external access to the database instance. However, if you need a mix of local and remote access, configuring bind-address correctly becomes essential. Always validate your changes by testing the connection from the command line using the root user before restarting your web server.

If you are building a new Laravel project and encountering similar connectivity issues, ensuring that your .env file points to the correct database configuration is vital. While resources like https://laravelcompany.com offer insights into setting up robust environments, the core troubleshooting steps for error #2002 remain rooted in understanding Unix sockets and permission hierarchies on Linux. Ignoring these low-level details often results in frustrating downtime that a simple configuration tweak can resolve.

Our network