Error
Error Code:
2025
MySQL Error 2025: Source Connection Failed
Description
MySQL Error 2025 indicates a failure from the client side to establish a connection with a MySQL server or a replication source. This error typically occurs when a client application or a replication replica attempts to connect but encounters an obstacle preventing the connection.
Error Message
Error connecting to source:
Known Causes
4 known causesNetwork Connectivity Problems
The client or replica cannot reach the MySQL server due to network outages, firewall blocks, or incorrect network configurations.
MySQL Server Unavailable
The target MySQL server instance is not running, has crashed, or is configured to reject connections from the client's IP address.
Invalid Connection Details
The client is attempting to connect using an incorrect hostname, IP address, port number, or other connection string details.
Firewall Blocking Connection
A firewall (either on the client, server, or network) is preventing the connection from being established on the specified port.
Solutions
3 solutions available1. Verify Network Connectivity and Firewall Rules easy
Ensure the MySQL client can reach the MySQL server over the network and that firewalls are not blocking the connection.
1
From the machine where your MySQL client (or replication source) is running, attempt to ping the MySQL server's hostname or IP address.
ping <mysql_server_hostname_or_ip>
2
If ping fails, check if the MySQL server is running and accessible on its configured port (default is 3306). Use telnet or nc (netcat) for this.
telnet <mysql_server_hostname_or_ip> 3306
3
If telnet/nc fails, investigate firewall rules on both the client and server machines, as well as any network firewalls in between. Ensure port 3306 (or your custom MySQL port) is open for inbound connections on the server and outbound connections from the client.
# Example: On a Linux server using iptables
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
4
On Windows, check Windows Firewall settings via `wf.msc` to ensure the port is allowed.
N/A (GUI operation)
2. Check MySQL User Permissions and Host Access medium
Confirm that the MySQL user account used for the connection has the necessary privileges and is allowed to connect from the specified host.
1
Connect to the MySQL server as a user with administrative privileges (e.g., root).
mysql -u root -p
2
Check the privileges for the user account being used for the source connection. Replace `<username>` and `<connecting_host>` with your actual values.
SHOW GRANTS FOR '<username>'@'<connecting_host>';
3
Ensure the user has appropriate privileges for replication (e.g., `REPLICATION SLAVE`, `REPLICATION CLIENT`) if this error occurs during replication setup. If not, grant them.
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO '<username>'@'<connecting_host>' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;
4
Verify that the user is allowed to connect from the client's host. The `<connecting_host>` can be a specific IP address, hostname, or a wildcard like '%' for any host (use with caution).
SELECT user, host FROM mysql.user WHERE user = '<username>';
5
If the user is not configured for the correct host, you may need to recreate the user or update its host. Example to update host:
RENAME USER '<username>'@'old_host' TO '<username>'@'<connecting_host>';
FLUSH PRIVILEGES;
3. Review MySQL Server Configuration (bind-address) medium
Ensure the MySQL server is configured to listen on the correct network interface that the client is attempting to connect to.
1
Locate your MySQL server's configuration file. Common locations include `/etc/my.cnf`, `/etc/mysql/my.cnf`, or within `/etc/mysql/conf.d/`.
N/A
2
Open the configuration file in a text editor with administrative privileges.
sudo nano /etc/mysql/my.cnf
3
Look for the `bind-address` directive under the `[mysqld]` section. If it's set to `127.0.0.1` or `localhost`, the server will only accept connections from the local machine.
[mysqld]
bind-address = 127.0.0.1
4
To allow connections from other machines, change `bind-address` to the server's IP address that the client will use, or to `0.0.0.0` to listen on all available network interfaces (use with caution and ensure strong firewall rules).
[mysqld]
bind-address = <server_ip_address>
# OR for all interfaces (less secure):
# bind-address = 0.0.0.0
5
Save the configuration file and restart the MySQL server for the changes to take effect.
sudo systemctl restart mysql