Skip to content
AcuGIS Connect Documentation

PostgreSQL Tunneling

A PostgreSQL / PostGIS connection forwards a port on this computer through SSH to PostgreSQL. AcuGIS Connect supplies the tunnel. It does not include pgAdmin, QGIS, or any other database administration window. It does not ask for a database password, run SQL, or change the database server.

Point the database client at 127.0.0.1 and the local port. Enter the database name, database user, and database password in that client.

Create the tunnel

  1. Click Add Connection.
  2. Set Type to PostgreSQL / PostGIS.
  3. Set the SSH server and authentication. See SSH Connections and SSH Authentication.
  4. Set the database address as the SSH server sees it.
Setting Typical value
Remote host 127.0.0.1 when PostgreSQL runs on the SSH server. Otherwise a private address that server can reach.
Remote port 5432
Local port 15432
  1. Click Save, select the profile, and click Connect.
  2. Approve the host key the first time, after you check its SHA256 fingerprint.

When the tunnel is up, the profile shows:

Host: 127.0.0.1
Port: 15432

Copy Connection Details copies those two lines. The port is the local port saved on the profile. If you chose a different local port, use that port in the database client.

The database client connects to your computer. AcuGIS Connect carries that TCP connection through SSH to the remote host and port. Keep AcuGIS Connect connected while the client is using the database. Disconnect closes this tunnel and leaves any other tunnel running.

If the status says the SSH tunnel is listening but the remote address is not reachable, SSH is up and the local port is open, but PostgreSQL did not accept a connection on the remote host and port. Check that address with the database administrator. AcuGIS Connect cannot change the server's PostgreSQL configuration.

Connect with pgAdmin

  1. Connect the tunnel in AcuGIS Connect.
  2. Click Copy Connection Details.
  3. In pgAdmin, register a server.
  4. On the connection settings, set Host to 127.0.0.1 and Port to the local port, 15432 unless you changed it.
  5. Enter the maintenance database, database username, and database password in pgAdmin.
  6. Leave pgAdmin's own SSH tunnel turned off. AcuGIS Connect is already forwarding the port. A second SSH tunnel in pgAdmin is not needed and will not use this connection profile.

pgAdmin stores its own database credentials. AcuGIS Connect does not see them.

Connect with QGIS

This example uses the default local port.

  1. Connect the PostgreSQL / PostGIS profile first.
  2. In QGIS, open Layer > Add Layer > Add PostGIS Layers.
  3. Click New.
  4. Set the host, port, and database:
QGIS field Value
Name A name you will recognize
Host 127.0.0.1
Port 15432
Database The database name
SSL mode disable or prefer
  1. Choose Basic authentication and enter the PostgreSQL user and password in QGIS.
  2. Test the connection, save it, and add the layers you need.

QGIS stores its own database credentials. Keep the tunnel connected while QGIS is using the layer. If AcuGIS Connect reports that the remote service is not reachable, the SSH tunnel is up but PostgreSQL did not accept a connection on the configured remote host and port.

Other database clients

Use the same host and port in DBeaver or another PostgreSQL client: 127.0.0.1 and the local port from Copy Connection Details. Enter the database user and password in the client. Do not configure a second SSH tunnel in the client.

Any program on this computer can connect to the local port while the tunnel is active. The PostgreSQL login is still required.