Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111 – ERROR FIXED!


So I finally decided to document this little issue I seem to have every time I need to set up a lamp server. The error Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111can be a pain in the butt if your unfamiliar with linux lamp servers.
To quickly ellaborate on the problem, the problem is 99.9% usually caused because of the following:

  1. Forgot to open/forward your mysql port (default 3306)
  2. Your forgot to edit your my.cnf and update your bound address (default
  3. Your hosts.allow is not setup to allow in any incoming connections to the server. ( mysqld: ALL: ALLOW )
  4. Correct user privileges have not been set to the remote user account in MYSQL.

This problem typically happens when you have 2 servers trying to communicate across the net. both servers are behind firewalls. The MYSQL Server by default comes bound with the localhost address ( Which becomes a problem when your local network is trying to forward sql packets to your server. Since your MYSQL server is bound to it will ignore any packet requests outside of its bound address.

To fix this issue simply check your LAN ip using your console/terminal.

Once you have your LAN ip you will want to go to your my.cnf (mysql config file) and edit the bound ip to your local LAN address (in some cases 192.168.1.x or 10.10.1.x etc…)

Run a second terminal window and sudo reboot your box.
once rebooted make sure you have created a mysql user with the correct remote access/permissions and log in.
At this point you should not be getting the error anymore. If you are check and make sure your scripts are using the correct credentials and selecting the correct database.

If you have any questions or require further assistance comment below.

Published by


I’m a bilingual Network Engineer. I have over 20 Years of Professional experience in Computer Science & Information Technology. I currently own and operate Web Semantics (www.websemantics.com) in Vancouver, Washington. I provide bilingual (English & Spanish) enterprise-level IT support to small and medium-sized businesses across the West Coast. *** Soy un ingeniero de redes bilingüe. Tengo más de 20 años de experiencia profesional en ciencias de la computación y tecnología de la información. Actualmente poseo y opero Web Semantics (www.websemantics.com) en Vancouver, Washington. Proporciono soporte de IT/Informática bilingüe (inglés y español) a nivel empresarial a pequeñas y medianas empresas en toda la costa oeste.

Leave a Reply