Lost Connection to MySQL server at 'reading initial communication packet' system error 0

Posted March 20, 2020 13.9k views

I have installed the OpenVPN server on the box and on the same box MySQL is hosted. Now if I try to connect to MySQL instance the following error appears.
“Lost Connection to MySQL server at ‘reading initial communication packet’ system error 0”
I have added the public IP of VPN in MySQL Access Host in WHM and cPanel nothing seems to work.

I did this because in Pakistan we have dynamic IPs so I would not let everyone try to hit the MySQL instance rather the access is given only to the VPN IP.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello, @hazhayder

Could you please provide us with the content of the MySQL configuration file? If you’ve binded the MySQL to localhost you can try to comment out the following line and then restart the MySQL service:


bind-address =


#bind-address =

Hope this helps!


  • This is the current my.cnf file.

    key_buffer_size = 8M
    • Hello, @hazhayder

      Thanks for sharing this, as far as I can see you don’t have the bind-address option in the config file so this one is checked.

      Can you examine the MySQL error_log file and see if there is a more detailed error that can help us with the troubleshooting?

      You can check the last 100 entries in the log:

      tail -n 100 /path-to-the-error-log-file.err

      you can get the full path with this command:

      grep "log-error" /etc/my.cnf

      You can also check if the MySQL service is currently still running or stuck:

      ps aux | grep mysql

      and also:

      netstat -plunt | grep mysqld


      netstat -plunt | grep 3306

      Can you confirm if you’ve followed the listed steps from this tutorial as well? This can help me to see what may have gone wrong with the MySQL service.


      by Jacob Tomlinson
      Here we'll install and configure OpenVPN on a CentOS 7 server. We'll also discuss how to connect a client to the server on Windows, OS X, and Linux. OpenVPN is an open-source VPN application that lets you create and join a private network securely over the public Internet.
      • Hey Alex,
        Thanks for your reply. I figured this out so actually when VPN is running my browsing IP is only changed to the VPN server’s IP. While the native application still runs on the real IP address. I got to know about this after I tried to logging into MySQL from MySQL workbench and checking into error log showed me my real IP Address.
        What is the work around for this?

        • Hello, @hazhayder

          I believe you can still access the database with MySQL workbench when using the VON. You can check the image bellow with the configured settings:

          See this image

          Also if you’re using any Firewall configuration within WHM/cPanel you make sure that the VPN IP address is enabled.

          Let me know how it goes.