Report this

What is the reason for this report?

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Posted on October 21, 2015

Hello,

I have two droplets, one with a database and one with a website. I have installed LAMP in both of them (except for the droplet that contains the website which does not have MySQL installed).

I tested the droplets with a simple index page which makes a simple connection to the database and brings text from it to be printed in the body and YES IT DOES WORK, so this confirms me that MySQL server is up and running.

However, when I upload a bigger website I get an error message that says:

Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

(Note that this bigger website works perfectly in localhost, running XAMPP)

First tip given was to change the droplet containing the database to one with more capacity, and I did that, however the problem persists.

Then I was told to change the bind address to 0.0.0.0 in “/etc/mysql/my.cnf”… I also did this and still nothing…

Any suggestion??

Thank’s in advanced



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This question was answered by @ryanpq:

It sounds like your app is attempting to connect to a MySQL service on the same server using /var/run/mysqld/mysqld.sock rather than attempting to connect via the service’s IP address and port. I would check your app’s configuration and ensure it is set up properly for your remote db server.

View the original comment

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.