Configure DB to Allow External Connections

Some databases by default don't allow external connections to connect to the DB. If that's the case please follow the below steps:

If you're using SSH tunneling and your bastion server is the same as your DB host, then you shouldn't need the below, since the DB connection will look like a local connection.

PostgreSQL

Open postgresql.conf (usually in /etc/postgresql/9.x/main/) and enable the following:

listen_addresses = '*'

Also, add the following lines to pg_hba.conf:

# TYPE  DATABASE   USER   ADDRESS              METHOD
host    all        all    128.199.219.128/32   md5
host    all        all    188.166.254.67/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