Connecting to the PostgreSQL database remotely (via an SSH Tunnel)

To make a connection to the database server from a remote machine you need to setup an SSH tunnel. Direct connections to the database server are firewalled to security reasons. The SSH tunnel provides a secure and authenticated means of talking to the database server.

The SSH tunnel maps a port on your machine to the same port on the database server.

Setting up an SSH tunnel using Putty

Startup Putty on your local machine.

Go to the Connection -> SSH -> Tunnels menu.

  1. In the section 'Port forwarding' set the source port to 5432
  2. Set the destination to
  3. Check the 'Local' option.
  4. Click the 'Add' button.

Then initialise an SSH connection to your web hosting account. Even if you are not using putty, the putty session needs to remain open to connect to the database.

Setting up an SSH Tunnel via the command line

From your terminal run the command:



  1. USERNAME is the username you use to connect to the server
  2. DOMAINNAME is your websites domain

Once this has been done you will be able to access the PostgreSQL database as if it was running on your own machine. This means you will be able to use localhost as the hostname and the usual PostgreSQL port 5432 as well as your usual postgreSQL database username and password.

If you need any assistance with this, please contact support at or 1300 883 979.