My website was working till a few days ago. It suddenly stopped working and showing white screen on every page only when some users including administrator are logging in to it. I added the following line at the top of the index.php

error_reporting(E_ALL); ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE); 

The following error is displaying

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /home/******/public_html/includes/database/database.inc:2204 Stack trace: #0 /home/******/public_html/includes/database/database.inc(2204): PDOStatement->execute(Array) #1 /home/******/public_html/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array) #2 /home/******/public_html/includes/database/database.inc(2383): DatabaseConnection->query('SELECT expire, ...', Array, Array) #3 /home/******/public_html/includes/lock.inc(167): db_query('SELECT expire, ...', Array) #4 /home/******/public_html/includes/lock.inc(146): lock_may_be_available('theme_registry:...') #5 /home/******/public_html/includes/theme.inc(449): lock_acquire('theme_registry:...') #6 /home/******/public_html/includes/bootstrap.inc(455): ThemeRegistry->set(Array) #7 [internal function]: DrupalCacheArray->__destruct() #8 {main} thrown in /home/******/public_html/includes/database/database.inc on line 2204

I really have no idea what to do. thanks in advance


99% of the times I've seen that error it is because the website is trying to save more data than the amount expected by MySQL.

It is fixed increasing the value of the mysql variable max_allowed_packet

The value of this variable is given in bytes, and by default it is set to 1048576 (1 Mb).

You can try to modify it to something bigger, like 4194304 (4 Mb) and keep increasing it to a value that do not give you this error.

Not the answer you're looking for? Browse other questions tagged or ask your own question.