Yeah, that one! You getting that too? Ripping your hair out? Here, have some of mine too!
I was getting an intermittenet error on a CENTOS 5 PHP 5.3 server. Hard to recreate as it occurred every few hours. This is what would show in the log: pdo connection error: sqlstate[ 2013 lost connection to mysql server at ‘reading initial communication packet’, system error: 113. 113 is ‘no route to host’, which means it is some goddam networking nightmare problem!
I have been ripping all the hair out of my head trying to fix this FUCKING error for a week straight! What a goddam nightmare! I have tried everything to fix it. I tested and reconfigured my network countless times. I tweaked mysql, and finally downloaded the binary rpms from mysql and did a fresh install. I poured over my PHP install.
But most of all, I searched google for days looking for discussion about this issue. I found lots of stuff but no difinitive answers. I also found the error popping up on sites all over the web – it is clearly occurring quite a bit.
What happens is the site seems just fine. I hit it repeatedly using the browser, and run thousands of siege tests – but no error. Then out of no where, maybe every hour or 2 I get the error again.
It was easy to blame mysql, as this bug discusses. But after I completely reinstalled it from the mysql rpms I had to rule that out. Either my network was flaky or the PHP server was causing it. One interesting thing is that I have a mirrored set of servers, a three tier front, back and database setup. The error was happening accross both setups, so it was clearly not a one off problem.
Oh so you are looking for a solution? Well … I can tell you what I found.
I am using symfony 1.4 which requires PHP 5.3. I have become old and lazy so I no longer have the energy to roll my own (compile) binaries. I searched around and found a site that had easy to install rpms using yum. The site is Webtatic. The author had all of the binaries I needed for PHP 5.3 so I just followed the instructions and BINGO I had a sweet PHP 5.3 setup!
Now, are these 3rd party rpms the cause of the problem or is it something in CENTOS 5? I really don’t know. But I do know that when I simply installed RHEL 6 and all the yummy PHP 5.3 stuff that comes with it, all was well. The error is gone – at least since I made the switch. If it comes back again, I will update this post.