# MySQL server has gone away

**URL:** https://forum.mautic.org/t/mysql-server-has-gone-away/10060
**Category:** Product Support
**Created:** [December 6, 2017, 1:59pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060 "2017-12-06T13:59:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mmifsud](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmifsud](https://forum.mautic.org/u/mmifsud)
#### Post date: [December 6, 2017, 1:59pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/1 "2017-12-06T13:59:16Z")

</div>

Hi,  
  
  
  
My colleagues at commercial created a new campaign with tracking, but we are having a strange issue. If we open the link with a browser that is signed in on Mautic web interface, the link opens/redirects normally. However, if we open it when logged out of Mautic, we get the following error:  
  
  
  
[2017-12-06 13:44:52] mautic.WARNING: PHP Warning - PDOStatement::execute(): MySQL server has gone away - in file /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php - at line 105 [] []  
  
[2017-12-06 13:44:52] mautic.WARNING: PHP Warning - PDOStatement::execute(): Error reading result set’s header - in file /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php - at line 105 [] []  
  
[2017-12-06 13:44:52] mautic.CRITICAL: Uncaught PHP Exception DoctrineDBALExceptionDriverException: “An exception occurred while executing…  
  
…  
  
General error: 2006 MySQL server has gone away at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\DBAL\Driver\PDOException(code: HY000): SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: HY000): SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)”} []  
  
  
  
Output truncated due to a very long query. The browser just outputs error 500 - Internal server error  
  
  
  
However, when opening same link when logged in, no errors are produced in the logs and link opens normally. We rebooted the server, did the following changes as per various posts found online to my.cnf:  
  
  
  
max\_allowed\_packet=100M # Went up to 400M  
  
innodb\_buffer\_pool\_size=512M  
  
query\_cache\_type=1 # 1 and 0  
  
wait\_timeout=28800  
  
  
  
Commercial removed and re-created campaign with no success.  
  
  
  
Setup running on Centos 7 fully updated as at 16th November, PHP 7.0.25 and fully updated Mautic.  
  
  
  
Spent the whole morning trying to figure out what is causing the issue, but can’t find why mysql/php is logging that error. Appreciate any help/suggestions you can provide.

---

<div class="post-metadata">

### Author: ![beppi](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@beppi](https://forum.mautic.org/u/beppi)
#### Post date: [December 22, 2017, 7:48am UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/2 "2017-12-22T07:48:40Z")

</div>

The same thing here… I installed fresh systems, fresh mautics and fresh databases for the whole day yesterday and today, everytime I get database errors, mariadb shutdowns without understandable errors and mautic’s log says that the connection with db was lost after receiving a php error.  
In addition, there’s no way to find anything in the documentation or in the forums because here I can only find questions, and google redirects me always to the old unexistant forum…  
Any help?

---

<div class="post-metadata">

### Author: ![javisr](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@javisr](https://forum.mautic.org/u/javisr)
#### Post date: [January 2, 2018, 7:07pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/3 "2018-01-02T19:07:16Z")

</div>

Same problem

---

<div class="post-metadata">

### Author: ![emelzky](https://avatars.discourse-cdn.com/v4/letter/e/7c8e57/32.png) [@emelzky](https://forum.mautic.org/u/emelzky)
#### Post date: [January 3, 2018, 5:17am UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/4 "2018-01-03T05:17:26Z")

</div>

I had same problem with 5.5.56-MariaDB. Updated database to 10.1.29-MariaDB and its working again.

---

<div class="post-metadata">

### Author: ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)
#### Post date: [February 6, 2018, 8:32am UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/5 "2018-02-06T08:32:05Z")

</div>

Also getting the same errors which seems to have started happening recently - had previously sent several thousand emails and then this error springs up, even when sending a single email.

Unsure what might have changed in the interim but will do a bit more digging!

---

<div class="post-metadata">

### Author: ![EdwardC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/edwardc/32/693_2.png) [@EdwardC](https://forum.mautic.org/u/EdwardC)
#### Post date: [April 5, 2020, 12:44pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/6 "2020-04-05T12:44:49Z")

</div>

Ive got a similar problem now, never had it before and now it happens… I have set the following in mysql

max\_allowed\_packet = 100M  
innodb\_log\_file\_size = 128M  
wait\_timeout = 28800

I am trying to send emails to about 300k people and seems the size of the set is the problem

The error occurs as such

```
 [Doctrine\DBAL\Exception\DriverException]

```

An exception occurred while executing ‘SELECT ch.lead\_id, IFNULL(fr.frequency\_number,?) as frequency\_number, IFNULL(fr.frequency\_time,?) as frequency\_time FROM pb\_email\_stats ch LEFT JOIN pb\_lead\_freque  
ncyrules fr ON ch.lead\_id = fr.lead\_id WHERE (fr.channel = ? or fr.channel is null) AND (ch.date\_sent \>= case fr.frequency\_time  
when ‘MONTH’ then DATE\_SUB(NOW(),INTERVAL 1 MONTH)  
when ‘DAY’ then DATE\_SUB(NOW(),INTERVAL 1 DAY)  
when ‘WEEK’ then DATE\_SUB(NOW(),INTERVAL 1 WEEK)  
else DATE\_SUB(NOW(),INTERVAL 1 WEEK)  
end) AND (ch.lead\_id IN (481342, 481354, 481356, 481365, 481386, 481390, 481412, 481429, 481448, 481457, 481459, 481461, 481467, 481468, 481471, 481478, 481480, 481482, 481486, 48149  
1, 481495, 481499, 481500, 481501, 481502, 481512, 481513, 481530, 481535, 481536, 481547, 481551, 481553, 481556, 481560, 481561, 481583, 481585, 481593, 481601, 481613, 481615, 481631, 481634, 481640,  
481646, 481662, 481664, 481665, 481678, 481680, 481695, 481696, 481701, 481705, 481709, 481714, 481723, 481735, 481737, 481748, 481753, 481773, 481776, 481788, 481790, 481792, 481806, 481809, 481817, 4  
81818, 481823, 481837, 481843, 481844, 481857, 481864, 481865, 481872, 481876, 481890, 481898, 481908, 481922, 481924, 481935, 481937, 481941, 481944, 481950, 481951, 481961, 481968, 481982, 481983, 481  
988, 481993, 481997, 482006, 482010, 482013, 482023, 482036, 482041, 482044, 482045, 482051, 482102, 482104, 482117, 482120, 482125, 482126, 482127, 482132, 482143, 482147, 482153, 482154, 482165, 48216  
7, 482184, 482192, 482204, 482209, 482211, 482217, 482220, 482222, 482230, 482240, 482246, 482251, 482255, 482257, 482259, 482262, 482268, 482275, 482279, 482288, 482302, 482313, 482323, 482324, 482327,  
482334, 482344, 482350, 482357, 482365, 482407, 482414, 482415, 482423, 482426, 482436, 482439, 482454, 482464, 482475, 482484, 482488, 482496, 482500, 482506, 482509, 482511, 482515, 482516, 482518, 4  
82531, 482532, 482533, 482534, 482540, 482545, 482546, 482568, 482569, 482571, 482572, 482577, 482579, 482583, 482584, 482589, 482591, 482599, 482600, 482604, 482617, 482623, 482626, 482627, 482639, 482  
640, 482647, 482653, 482657, 482665, 482679, 482686, 482689, 482691, 482700, 482708, 482710, 482711, 482723, 482741, 482745, 482752, 482753, 482754, 482757, 482762, 482763, 482765, 482767, 482773, 48278  
0, 482791, 482798, 482803, 482806, 482816, 482825, 482833, 482844, 482850, 482852, 482869, 482877, 482886, 482890, 482896, 482901, 482908, 482910, 482920, 482927, 482930, 482937, 482938, 482944, 482949,  
482959, 482964, 482978, 482986, 482989, 482990, 482991, 482993, 482994, 482996, 483004, 483008, 483015, 483024, 483033, 483043, 483052, 483053, 483059, 483062, 483068, 483069, 483071, 483078, 483089, 4  
83097, 483100, 483114, 483118, 483124, 483125, 483129, 483145, 483158, 483165, 483168, 483174, 483181, 483190, 483216, 483233, 483240, 483242, 483249, 483257, 483260, 483264, 483266, 483273, 483279, 483  
289, 483293, 483306)) GROUP BY ch.lead\_id, fr.frequency\_time, fr.frequency\_number HAVING (count(ch.lead\_id) \>= IFNULL(fr.frequency\_number,?) AND ch.lead\_id IN (481342, 481354, 481356, 481365, 481386, 48  
1390, 481412, 481429, 481448, 481457, 481459, 481461, 481467, 481468, 481471, 481478, 481480, 481482, 481486, 481491, 481495, 481499, 481500, 481501, 481502, 481512, 481513, 481530, 481535, 481536, 4815  
47, 481551, 481553, 481556, 481560, 481561, 481583, 481585, 481593, 481601, 481613, 481615, 481631, 481634, 481640, 481646, 481662, 481664, 481665, 481678, 481680, 481695, 481696, 481701, 481705, 481709  
, 481714, 481723, 481735, 481737, 481748, 481753, 481773, 481776, 481788, 481790, 481792, 481806, 481809, 481817, 481818, 481823, 481837, 481843, 481844, 481857, 481864, 481865, 481872, 481876, 481890,  
481898, 481908, 481922, 481924, 481935, 481937, 481941, 481944, 481950, 481951, 481961, 481968, 481982, 481983, 481988, 481993, 481997, 482006, 482010, 482013, 482023, 482036, 482041, 482044, 482045, 48  
2051, 482102, 482104, 482117, 482120, 482125, 482126, 482127, 482132, 482143, 482147, 482153, 482154, 482165, 482167, 482184, 482192, 482204, 482209, 482211, 482217, 482220, 482222, 482230, 482240, 4822  
46, 482251, 482255, 482257, 482259, 482262, 482268, 482275, 482279, 482288, 482302, 482313, 482323, 482324, 482327, 482334, 482344, 482350, 482357, 482365, 482407, 482414, 482415, 482423, 482426, 482436  
, 482439, 482454, 482464, 482475, 482484, 482488, 482496, 482500, 482506, 482509, 482511, 482515, 482516, 482518, 482531, 482532, 482533, 482534, 482540, 482545, 482546, 482568, 482569, 482571, 482572,  
482577, 482579, 482583, 482584, 482589, 482591, 482599, 482600, 482604, 482617, 482623, 482626, 482627, 482639, 482640, 482647, 482653, 482657, 482665, 482679, 482686, 482689, 482691, 482700, 482708, 48  
2710, 482711, 482723, 482741, 482745, 482752, 482753, 482754, 482757, 482762, 482763, 482765, 482767, 482773, 482780, 482791, 482798, 482803, 482806, 482816, 482825, 482833, 482844, 482850, 482852, 4828  
69, 482877, 482886, 482890, 482896, 482901, 482908, 482910, 482920, 482927, 482930, 482937, 482938, 482944, 482949, 482959, 482964, 482978, 482986, 482989, 482990, 482991, 482993, 482994, 482996, 483004  
, 483008, 483015, 483024, 483033, 483043, 483052, 483053, 483059, 483062, 483068, 483069, 483071, 483078, 483089, 483097, 483100, 483114, 483118, 483124, 483125, 483129, 483145, 483158, 483165, 483168,  
483174, 483181, 483190, 483216, 483233, 483240, 483242, 483249, 483257, 483260, 483264, 483266, 483273, 483279, 483289, 483293, 483306))’ with params [“3”, “WEEK”, “email”, “3”]:

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

---

<div class="post-metadata">

### Author: ![leonsmit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/leonsmit/32/486_2.png) [@leonsmit](https://forum.mautic.org/u/leonsmit)
#### Post date: [October 7, 2020, 8:35am UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/7 "2020-10-07T08:35:25Z")

</div>

Same issue here, it was working fine till a couple of days ago and now when i try to send the rest of the set it just gives this error without really sending anything…

Trying to send a mailing to 80k contacts.

---

<div class="post-metadata">

### Author: ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)
#### Post date: [October 7, 2020, 12:34pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/8 "2020-10-07T12:34:21Z")

</div>

how much disk space do you have left ?  
do you have ssh access

---

<div class="post-metadata">

### Author: ![lanaprinzip](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lanaprinzip/32/4481_2.png) [@lanaprinzip](https://forum.mautic.org/u/lanaprinzip)
#### Post date: [February 21, 2021, 6:33am UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/9 "2021-02-21T06:33:50Z")

</div>

Same issue here, it happens when I simply try to delete an email message under channels email:  
I raised the question here: [Message frequency rule and email delete issue - Support - Mautic Community Forums](https://forum.mautic.org/t/message-frequency-rule-and-email-delete-issue/18232/3)

The error:Warning xxxx AH01071: Got error ‘PHP message: PHP Warning: mysqli\_stmt::execute(): MySQL server has gone away in /var/www/vhosts/private.dom/mautic path/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php on line 150PHP message: PHP Warning: mysqli\_stmt::execute(): Error reading result set’s header in /var/www/vhosts/mautic path /vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php on line 150’, referer: [https://private.dom/s/emails](https://private.dom/s/emails)

Has anyone found a fix? Right now we are only in testmode with some testaccounts with a fresh installation.  
Tnx

---

<div class="post-metadata">

### Author: ![m.abumusa](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/m.abumusa/32/741_2.png) [@m.abumusa](https://forum.mautic.org/u/m.abumusa)
#### Post date: [February 22, 2021, 8:08pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/10 "2021-02-22T20:08:59Z")

</div>

It might be the SQL server running on the same server that runs apache, so the memory got consumed so MySQL server turn off so you would see the error.

I don’t think it is MySQL or mariadb version issue

---

<div class="post-metadata">

### Author: ![lanaprinzip](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lanaprinzip/32/4481_2.png) [@lanaprinzip](https://forum.mautic.org/u/lanaprinzip)
#### Post date: [February 23, 2021, 12:18pm UTC](https://forum.mautic.org/t/mysql-server-has-gone-away/10060/11 "2021-02-23T12:18:54Z")

</div>

Thank you for the hint!

I was able to find the solution:

The error is caused, as I had not installed a Cron Job " /bin/console mautic:broadcasts:send --channel=email" yet.  
This caused a pending email in the email that I tried to delete. This caused the fatal error of the DB.  
After the Cron ran, the delete process worked fine.
