"Can't connect to local MySQL server through socket" Error

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Registered User
Posts: 2
Joined: Fri Jan 16, 2015 10:30 pm

"Can't connect to local MySQL server through socket" Error

Post by ScottBoyMurphy »

Ok, so my work used to run a forum which has now moved onto a Facebook group. We are closing down the webspace and are moving the forums to some unused webspace I have.

Today I sucessfully downloaded everything and set it up on my laptop, then updated it from 3.0.8 to the latest version. Everything works great on my laptop. I then uploaded it to my webspace and now I get (I've changed the config.php to the new database settings);

General Error
SQL ERROR [ mysql4 ]

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [2002]

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
I have even taken the config.php from the webspace and put it into my local install, which then connects with no problems. Further more I have written the following script;

Code: Select all

    ini_set( 'display_errors','1'); 

    $mysqli = mysqli_connect('', 'groomermill', '8xAog5AhnUZ8VBSd', 'groomermill');
    if (mysqli_connect_errno($mysqli))
        echo "Failed to connect to MySQL: " . mysqli_connect_error();

    $res = mysqli_query($mysqli, 'SELECT * FROM `phpbb_users` WHERE `username_clean`="scott"');
    if (!$res)
        echo "Nothing returned";
        $row = $res->fetch_assoc();
        echo 'UserID: ' . $row['user_id'];
I put that in the root of the forums and navigated to it. It works fine. So phpBB can connect to the remote database (the install on my local machine), and the script on the server can also connect to it, but phpBB on the server cannot adn gives me the error above.

I've tried uploading the files again and check everything is perfect. I'm totally stumped and after 3 hours of messing about I need some fresh eyes on the problem.
User avatar
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: "Can't connect to local MySQL server through socket" Error

Post by Oyabun1 »

ScottBoyMurphy wrote:I've changed the config.php to the new database settings
There should have been no need to change that file. Recheck the changes you made.

My guess would be that /var/lib/mysql/mysql.sock doesn't exist on the server, therefore, the correct value of the $dbhost variable in /config.php file may not be localhost.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
Registered User
Posts: 2
Joined: Fri Jan 16, 2015 10:30 pm

Re: "Can't connect to local MySQL server through socket" Error

Post by ScottBoyMurphy »

I had to change the config file as the database has also moved. First onto my local machine so I could update it, as it was a MySQL 3/4 schema and the new server runs version 5. That all went fine and as I said my local copy works perfect.

I then had to change it again for the settings of the new remote server. Those remote db settings work fine on my local install of phpbb, but on the install on my webspace, I was getting the error mentioned above.

This morning though I have had another mess around. After deleting the files in the cache folder the board now connects to the database and shows the following message;
Sorry but the board is temporarily unavailable, please try again in a few minutes.
I can login as administrator and see all the forums, however I cannot reactivate the board. Each time I try to change the disable board setting to no, I am told my settings were updated, but on returning to the page the board is still set to disabled. I can change the message that is displayed so it is not permission issues with the database.

Just had a google and seen some people were having this problem due to the Limit system load settings being 0. Mine was 0 and I have now change that to 1 and it has saved. However I still cannot enable the board.

UPDATE: Played around with the limit system load settings and it seems setting it to 4 lets me enable the boards. Is this an acceptable setting or is this going to cause issues in future?

Return to “[3.1.x] Support Forum”