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

  • Posted September 14, 2013

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?


Submit an 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.

Ah, okay. Thanks for trying to help, Pablo. :)

@Aahan, <br> <br>On the install page you cited, there’s a field titled <b>Database Host</b>; which creates the <code>define( ‘DB_HOST’, ‘localhost’ );</code> line in the <code>wp-config.php</code> file. <br> <br>The point of my initial post was to make sure that <code>localhost</code> had not been inadvertently entered, as the <b>Database Host</b> in the install page, if the goal was to have WordPress connect to a remote database. <br> <br>In any event, glad you got it working.

Hello Pablo, <br> <br>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. <br> <br>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.

The relevant variable is located in <code>wp-config.php</code>. Look for the line that reads: <br> <br><code>define( ‘DB_HOST’, ‘localhost’ );</code> <br> <br>and change <code>localhost</code> to the private IP address of your database server. You can read more about this in the <a href=“”>WordPress Codex</a>; and you can create a <b>wp-config.php</b> file @ <a href=“”>GenerateWP</a>.