MY Mysql flexiable database is not allowing connections ?

Nkugwa Mark William 0 Reputation points
2025-05-31T15:34:02.3466667+00:00

I keep getting this when trying to connect to my MySQL flexible database, and please, it's not the firewall. I have made the database open to anyone, and it still gets that even databases where I clearly could do that before are now not connecting. What's wrong?
Enter password: 

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 54

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
969 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andriy Bilous 11,816 Reputation points MVP Volunteer Moderator
    2025-05-31T20:56:57.9266667+00:00

    Hello Nkugwa Mark William

    This error indicates that the client established a TCP connection to the server, but the connection was lost during the initial handshake phase. Even if you've configured the firewall to allow all IPs, other factors might be contributing to this issue.

    The connection was established, but it was lost afterwards. This can happen if a connection is attempted against something that isn't MySQL (like using a MySQL client to connect to SSH on port 22 for example). It can also happen if the super user kills the session. It can also happen if the database times out the session. Or it can refer to issues in the database server, after the connection is established. This can happen at any time during the lifetime of the client connection. It can indicate that the database had a serious issue.
    https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-troubleshoot-connectivity-issues

    To solve the issue try:

    1. Public Access & Networking Mode
    • Ensure your server is using public access (allowed IPs) or private access (via VNet) depending on your use case. Go to Azure Portal > Your MySQL Flexible Server > Networking If Private access is selected, ensure your client is inside the same VNet/subnet. If Public access, ensure your IP (or 0.0.0.0 - 255.255.255.255 for open) is allowed.
    1. SSL Configuration
    • Azure MySQL Flexible Server enforces SSL by default. If you're using a command like: mysql -h <server-name>.mysql.database.azure.com -u <username>@<server-name> -p Then either Use the --ssl-mode=REQUIRED flag, or disable SSL in server settings only for testing purposes (not recommended in production). mysql --ssl-mode=REQUIRED -h <server>.mysql.database.azure.com -u <user>@<server> -p
    1. Server Logs
    • Check the Server Logs in Azure Portal. Go to Azure > MySQL Flexible Server > Server Logs Look for entries that correspond to failed connection attempts — particularly anything mentioning handshake, SSL negotiation, or dropped packets.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.