Got Error "MySQL server has gone away"? what is the solution for this?

Posted March 30, 2018 15.6k views
MySQLApachePHP FrameworksUbuntu 16.04

I got these 2 error

  1. “Packets out of order. Expected 0 received 45. Packet size=4739923” &
  2. “SQLSTATE[HY000] [2006] MySQL server has gone away” HELP ME Same application working other server but it’s not working here, please help me.
  • @gdlc

    How are you connecting to the database? Please post the code.

    You can also post the last few lines of mysql error log to help you solving the problem.

  • My PHP is in server and database is in server, and also added
    bind-address =

    Connection COde
    ‘mysql’ => [
    'driver’ => 'mysql’,
    'host’ => env('DBHOST’, '’),
    'port’ => env('DB
    PORT’, '25000’),
    'database’ => env('DBDATABASE’, 'g#######’),
    'username’ => env('DB
    USERNAME’, 'g*******’),
    'password’ => env('DBPASSWORD’, ’m########’),
    'charset’ => 'utf8’,
    'collation’ => 'utf8
    'prefix’ => “,
    'strict’ => false,
    'engine’ => null,
    'timezone’ => ’+05:30’,
    //DBNAME, USERNAME, PASSWORD hide in this code

    For Error Log, Check this link

  • Waiting for your valuable suggestion, please suggest me

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
2 answers

Your mysql server has probably timed out and might be fixed by checking if the waittimeout mysql variable in your mysql configuration file (my.cnf) is large enough. It could also be caused by an incorrect or a too large packet. You can fix this by increasing the packet size limit maxallowed_packet in my.cnf file. After doing above restart your mysql server.

I already increased maxallowed_packet and restart mysql, but that problem is not solved. Please give any other solution to solve this issue.