PostgreSQL and AWS RDS with a static IP
Keep port 5432 closed to the public internet while connecting to PostgreSQL and AWS RDS from serverless, CI, or behind a private NAT.
First payment refunded within 7 days if it doesn’t work for you
- PostgreSQL
On this page12
PostgreSQL uses its own binary wire protocol directly over TCP (port 5432), so standard HTTP_PROXY variables do not apply. Outbound connections to an allowlisted cloud database run over prontaro forward or socks5h://, while inbound access to a private database uses a locked-down TCP tunnel with IP rules.
Which scenario do you need?
| Scenario | Prontaro tool | Minimum plan |
|---|---|---|
| 1. Connect from serverless, CI, or laptop to allowlisted RDS / Postgres | prontaro forward or socks5h:// |
Dedicated ($12/mo) or Pro |
| 2. Give your team access to a private Postgres behind NAT without a VPN | prontaro tcp 5432 + prontaro access |
Tunnels ($6/mo, persistent port on a shared IP) or Dedicated/Pro (port 5432 on your IP) |
Scenario 1. Outbound connection to PostgreSQL / AWS RDS
Instead of opening your database to 0.0.0.0/0, allowlist only your single dedicated Prontaro IPv4 (/32).
Step 1. Allowlist your static IP on the database
AWS RDS
Open the Security Group attached to your RDS instance and add an inbound rule for TCP 5432 scoped to your /32:
- Type / Port
- PostgreSQL (TCP 5432)
- Source
- 203.0.113.10/32
- Description
- prontaro-static-ip
(Your RDS instance must have Publicly accessible = Yes so external connections from your allowlisted IP can reach its endpoint.)
Self-hosted PostgreSQL (pg_hba.conf)
Add a TLS-only (hostssl) rule in pg_hba.conf and reload PostgreSQL without a restart:
# /etc/postgresql/16/main/pg_hba.conf
hostssl app_db app_user 203.0.113.10/32 scram-sha-256SELECT pg_reload_conf();Step 2. Create credentials and verify the outbound IP
If you connect directly from serverless code over socks5h://, create dedicated proxy credentials in the dashboard (for prontaro forward, a logged-in prontaro CLI or PRONTARO_KEY is all you need). Verify the IP against api.ipify.org first, then restrict allowed destinations.
- Open IP addresses → Proxy credentials in my.prontaro.com, create credentials named
pg-prod, and copy thesocks5h://...:1080URL. - Leave destination rules open for the IP check below.
Confirm the SOCKS5 route exits from your dedicated static IPv4:
curl -fsS --proxy "socks5h://u_pg:s3cr3t@<entry>.prontaro.io:1080" https://api.ipify.org
203.0.113.10Now lock pg-prod down to your PostgreSQL host on port 5432:
- Open IP addresses → Proxy credentials in my.prontaro.com, select
pg-prod, and switch to Access. - Add
*.rds.amazonaws.com:5432(or your exact database host) under To and save.
Step 3A. Connect via prontaro forward (psql, Prisma, SQLAlchemy, Go, CI)
Forward your remote PostgreSQL server to 127.0.0.1:15432:
prontaro forward 15432 mydb.xxxx.eu-central-1.rds.amazonaws.com:5432 --ip 203.0.113.10prontaro forward 15432 mydb.xxxx.eu-central-1.rds.amazonaws.com:5432
127.0.0.1:15432 → mydb.xxxx.eu-central-1.rds.amazonaws.com:5432 from your IP 203.0.113.10Verify the connection and check what IP PostgreSQL sees:
psql "postgresql://app_user@127.0.0.1:15432/app_db?sslmode=verify-ca&sslrootcert=global-bundle.pem" -c "SELECT inet_client_addr();"
inet_client_addr
------------------
203.0.113.10
(1 row)Step 3B. Connect via socks5h:// from serverless (Node.js pg + socks)
In Vercel Functions, AWS Lambda, or Cloud Run — where running a background prontaro forward process is inconvenient — connect directly through socks5h://. Example with Node.js pg and socks (npm install pg socks), keeping strict TLS hostname verification (servername):
// db.mjs
import { Client } from 'pg';
import { SocksClient } from 'socks';
const proxy = new URL(process.env.PRONTARO_SOCKS_URL); // socks5h://...
const dbHost = process.env.PGHOST;
const dbPort = Number(process.env.PGPORT ?? 5432);
const { socket } = await SocksClient.createConnection({
proxy: {
host: proxy.hostname,
port: Number(proxy.port),
type: 5,
userId: decodeURIComponent(proxy.username),
password: decodeURIComponent(proxy.password),
},
command: 'connect',
// Pass the hostname so DNS resolves on the Prontaro node (socks5h)
destination: { host: dbHost, port: dbPort },
timeout: 10_000,
});
const client = new Client({
host: dbHost,
port: dbPort,
database: process.env.PGDATABASE,
user: process.env.PGUSER,
password: process.env.PGPASSWORD,
stream: () => socket,
ssl: {
rejectUnauthorized: true,
servername: dbHost,
},
});
await client.connect();
const { rows } = await client.query('SELECT inet_client_addr() AS ip');
console.log('Connected from static IP:', rows[0].ip);
await client.end();Scenario 2. Secure inbound access to a private database via prontaro tcp 5432
If PostgreSQL runs on an office server, private subnet, or workstation behind NAT, you can expose it safely to trusted clients without setting up a VPN or router port forwarding.
New TCP tunnels are closed to everyone by default — packets from non-allowed IPs are dropped by the kernel filter on the Prontaro node before a TCP handshake completes.
Step 1. Start the TCP tunnel on the database host
On Dedicated and Pro, open standard port 5432 directly on your dedicated IPv4 (on Tunnels, pass --to shared to get a persistent high port on a shared IP):
prontaro tcp 5432 --name pg-private --to 203.0.113.10After starting the tunnel, allow only the source IPv4 addresses or CIDR ranges that should reach the database.
Step 2. Allow only trusted source IPs
- Open Tunnels → Access in my.prontaro.com and select
pg-private. - Add the allowed IPv4 addresses or CIDR blocks and save.
Allow an explicit IPv4 address or CIDR range (for example, your office or CI server IP):
prontaro access pg-private allow 198.51.100.7Expected output:
✓ pg-private now open only to 198.51.100.7/32 (was: closed); takes effect within seconds.Step 3. Connect from an allowed machine
psql "postgresql://app_user@203.0.113.10:5432/app_db?sslmode=require" -c "SELECT version();"
PostgreSQL 16.4 ...To keep the tunnel running across reboots, install it as a background service (prontaro service install -- tcp 5432 --name pg-private --to <your-IP>) — see Run as a service.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
no pg_hba.conf entry for host "203.0.113.10" |
IP is missing from pg_hba.conf or config wasn’t reloaded. |
Add <your-IP>/32 to pg_hba.conf and run SELECT pg_reload_conf();. |
| Connection to AWS RDS times out | <your-IP>/32 is missing from the Security Group, or RDS Publicly accessible is off. |
Check Security Group inbound rules (TCP 5432) and confirm RDS public accessibility. |
certificate is valid for ..., not 127.0.0.1 |
sslmode=verify-full used over prontaro forward on 127.0.0.1. |
Use sslmode=verify-ca with sslrootcert, or map the hostname in /etc/hosts / driver servername. |
403 from SOCKS5 proxy |
Database host is not in the To list, or socks5:// was used without h. |
Use socks5h:// and allow *.rds.amazonaws.com:5432 in the credentials’ Access tab. |
Connection to prontaro tcp 5432 times out |
New TCP tunnels start closed to everyone. | Run prontaro access pg-private allow 198.51.100.7 (or add the IP in the dashboard). |
Next steps
- Connect to MongoDB Atlas — connect to Atlas clusters over
socks5h://orprontaro forward. - Local port forwarding (
prontaro forward) — full reference for outbound TCP forwarding and TLS certificate verification. - TCP tunnels — expose databases and other TCP services on your dedicated IPv4 or a persistent port on a shared IP.
- SSH, SFTP, and databases behind NAT — practical setups for secure access to private servers without a VPN.
- Access control & firewalls — restrict inbound tunnel traffic to approved IPv4 addresses and CIDR blocks.
Related guides
- Local port forwarding (prontaro forward)Connect database drivers, SFTP clients, and CLI tools to remote servers from your static IPv4 over a local TCP port — no proxy support needed.
- HTTP & SOCKS5 proxyRoute outbound HTTP, HTTPS, and TCP connections through your static IPv4 with one proxy credential set, end-to-end TLS, and From/To rules.
- Static IP for SupabaseRoute Supabase Edge Functions through a dedicated IPv4 and connect to Postgres behind Network Restrictions from CI, apps, or psql.
Something wrong on this page? Contact us