Wordpress App Server Unable To Connect With Database Server Over Private Network

September 14, 2013 3.4k views
I have my app (WordPress) and database on separate servers. I've made sure that the database server only talks on the private network (new feature from DO) and only allows the app server to talk to it over the former's private IP. So, when I try to install wordpress via it's unable to connect with the database because it's contacting the DB server from its public IP, hence giving me this, "Error establishing a database connection". Is there a way to make sure that wordpress connects with the database over private IP? For clarity here are the relevant settings in use on my database server: Any idea what I am doing wrong there?
4 Answers
The relevant variable is located in wp-config.php. Look for the line that reads:

define( 'DB_HOST', 'localhost' );

and change localhost to the private IP address of your database server. You can read more about this in the WordPress Codex; and you can create a wp-config.php file @ GenerateWP.
Hello Pablo,

When running the installer at there's no need to touch the wp-config.php file. When you provide all the database info on the installation screen, WordPress will automatically create the wp-config.php for you. So, no, that wasn't the problem.

Thanks to Will Rowe (Support Specialist at DigitalOcean), the issue turned out to be some characters in the password of the database user that MySQL didn't like.

On the install page you cited, there's a field titled Database Host; which creates the define( 'DB_HOST', 'localhost' ); line in the wp-config.php file.

The point of my initial post was to make sure that localhost had not been inadvertently entered, as the Database Host in the install page, if the goal was to have WordPress connect to a remote database.

In any event, glad you got it working.
Ah, okay. Thanks for trying to help, Pablo. :)
Have another answer? Share your knowledge.