By theone
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 http://example.com/wp-admin/install.php 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: https://gist.github.com/aahan/56bf2860929a8f98b1a6
Any idea what I am doing wrong there?
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!
Hello Pablo, <br> <br>When running the installer at http://example.com/wp-admin/install.php 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=“http://codex.wordpress.org/Editing_wp-config.php”>WordPress Codex</a>; and you can create a <b>wp-config.php</b> file @ <a href=“http://generatewp.com/wp-config/”>GenerateWP</a>.
@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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.