Hi !

I'm new to making a site with drupal. I've made my site locally on wamp, no problem there. But when i imported my site to a host (no problem with FTP nor with my databases imports) and i modify the settings.php with no problem (i think), i get this error message when i try to go to my site :

PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in lock_may_be_available() (line 167 of /homez.488/niksi/www/includes/lock.inc).

What can i do about it ? Have i made something wrong ?

Thanks a lot for your future replies :)



anruether’s picture

I also get this message sporadically...using 7.8

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in lock_may_be_available() (line 167 of PATH/includes/lock.inc).

Maxdrup’s picture

Not sure of the answer as to "why" but I replaced my settings.php file from my back up and this kickstarted it for me.

Note: definitely a newbie so this is anecdotal at best.

sarandi’s picture

I had this happen to me just now - the issue was the database host was something other than localhost/

On shared servers especially, make sure you check this, as their database configurations are generally a bit more convoluted.

smilingcrocodile’s picture

I solved my problem some times ago by reinstalling everything directly on the server... (I'm kind of new at this) But i think you are right, i did change those settings, but I think i just forgot to undo the "read only" of the settings.php file (What a noob ! ><). But i'll never be sure as I resarted everything new online...

So for the other ones as noob as me, check well if your read only box is not clicked, mayby it'll helpo you.

dhakshinait’s picture

Yes.it works.i changed my host name 'localhost' to my server db host name.my site is working now

naresh.kotha’s picture

Thanks dhakshinait

it works for me by changing host name to "db host name" then my site is working fine..,for example I changed
in 'host'=> 'localhost' to as below in settings.php


Thank you

mike stewart’s picture

Happened to me when re-setting my environment and accidentally using the wrong settings.php file. In other words, when I was moving my local setup, the settings.php file for my server config was used accidentally. I changed to the correct settings for my local mysql setup and everything worked fine.

It seems to confirm that if Drupal can't find the server, this error is returned

a_L_p’s picture

I had the same issue with a client who used godaddy for hosting, they have a support article listed below that helps you find the database host:


Changing $databases['host'] in settings.php to that obscure value did the trick!

Hope this helps someone down the road.

carsonblack’s picture

On my host the port was non-standard. I changed the 'port' setting in settings.php and these errors went away.

frops’s picture

you may have incorrectly entered the port

ressa’s picture

I had to change the host from 'localhost' to the actual server address (like "mysql10.example.com") which fixed it.

Try Drupal 8 at simplytest.me
Mhanote’s picture

I have received the error:

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in lock_may_be_available() (line 167...

The problem was that the settings.php was overwritten when I tried to find a fix for the memory solution to set the memory up to 124M or even higher. By changing the file, the values for the server and log in have been overwritten.

Check if the values are correct. That means all the log in Data are correct. For me it starts in line 213 right after the green text. :)

Found in folder: sites/default/settings.php (not default.settings.php)

$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'Your DATA BASE NAME', - if not sure look at the MYSQL at your host provider or local installation
'username' => 'Your USER NAME for this data base',
'password' => 'Your log in for this data base',
'host' => 'your host', - for example Dreamhost is mysql.example.com
'port' => '',
'driver' => 'mysql',
'prefix' => '',

This should work. All other solutions did not help.

I think the problem was cause by uploading the file and the file from my local installation brought over the setting from there. So the Online installation could not start because of the wrong log in settings.

I hope that helps!

sirreepicheep’s picture

I was having this error, I logged on to the LAMP server to begin troubleshooting and found that I could not write anything to the root partition. Everything I tried to do came back as readonly. Figured I was going to be restoring from backup but tried a to reboot and run fsck, which did work. FSCK found and repaired multiple file corruption on the root partition. So far working without error now, but keeping a close eye on it. Just another possible cause/solution.

alexkb’s picture

For those people using memcached module, you'll see a similar error to the one in this thread, if the memcached service isn't running. Just start it up via "/etc/init.d/memcached start" and you should be right.