Skip to main content

Allow Remote DB Connections

If you use Direct Connection method and run into this error "Could not connect to server: Connection refused", it's likely that you haven't configured your database to allow remote database connection.

If that is the case, please follow these steps:

NOTE

These IP addresses mentioned below are provided solely as an illustrative example for the SGP region. They are not universally applicable and should not be blindly whitelisted.

We strongly recommend whitelisting the IP addresses that correspond to your specific region. For a comprehensive list of IP addresses associated with Holistics, please refer to this documentation.

PostgreSQL

Open postgresql.conf (usually in /etc/postgresql/<version>/main/) and enable the following:

listen_addresses = '*'

Also, add the following lines to pg_hba.conf (please replace the IP addresses based on your actual server locations)

# TYPE  DATABASE   USER   ADDRESS              METHOD
host all all 188.166.198.14/32 md5
host all all 188.166.196.151/32 md5

And restart your database to take effect:

sudo service postgresql restart

MySQL

Open my.conf and comment out bind-address line:

# bind-address = 127.0.0.1

Then restart MySQL for the change to take effect:

sudo /etc/init.d/mysql restart
# or
sudo service mysql restart

If you are using SSH tunneling and your bastion server is the same as your DB host, then the steps above are not necessary since the DB connection will look like a local connection.


Let us know what you think about this document :)