I’ve setup 2 droplets both running Ubuntu 16.04 x64 and enabled private network on both.

I’ve got my Wordpress files on one droplet and my database on a separate droplet.

I’ve edited /etc/mysql/mysql.conf.d/mysqld.cnf on the database server and changed the bind-address to be the private IP of the database server.

I’ve also run ‘sudo ufw allow from WEB-SERVER-PRIVATE-IP to any port 3306 proto tcp’. Where WEB-SERVER-PRIVATE-IP is the wordpress files server private IP address.

I’ve edited the wordpress wp-config file: define('DB_HOST’, 'DATABASE-PRIVATE-IP’); Where DATABASE-PRIVATE-IP is my database server private IP address.

I get “Error establishing a database connection”

Where have I gone wrong?


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.

Submit an Answer
1 answer


In addition to allowing remote connections through the firewall and network interface, you will also need to add a MySQL user that is allowed to authenticate remotely. By default, most users should be allowed to connect only from localhost.

To do that, run mysql -u root -p and enter your MySQL root password and run the following command to add the user:

GRANT ALL ON database_name.* TO username@xx.xx.xx.xx IDENTIFIED BY 'your_password';

Make sure you replace the red parts with the relevant details, with xx.xx.xx.xx being the private IP of the web server. The username doesn’t have to be unique, as long as the host and username combination is unique.

Once you’ve done that, run


while still in the MySQL prompt in order to have it reload the privileges/credentials table and you should then be able to connect to the database from your web server.