Question

Wordpress Unable to Connect to remote DB over Private Networking

I have wordpress setup on two separate droplets. Files are on one droplet and DB is on a separate droplet. wp-config.php was edited with DB_HOST reflecting the private IP of the DB server.

This has suddenly stopped working - site is give me a “error connecting” message. However, if I use the public IP of the DB server, then the site works.

Anything I’m missing?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Found a fix/hack that seems to work for now: I backed up sql, deleted the mysql DBs that weren’t connecting through private IP, recreated DB and restored data and it magically works. Any idea what the problem is?

Follow up - I don’t know if it was the repeated restarting of mysql or what it was, but I can now connect to 2/3 of my databases using both private and public IPs. However, I get this error when I try to access the 3rd remote DB using the exact same file:

Could not select database: Access denied for user

Thanks for helping with this.

pinging works.

I was also able to manually connect using the mysql command, both to the public and private IP.

ifconfig shows both eth0 and eth1

Private IP just won’t work if I try to access from PHP files or wordpress.