pgquery

pgquery / Connect to Amazon RDS

Guide · Connect

Connect pgquery to Amazon RDS

RDS and Aurora are PostgreSQL behind an AWS endpoint. The work is mostly networking: pgquery has to be allowed to reach the database.

1. Find the endpoint

  1. In the AWS console, open RDS → Databases and select your instance (or the Aurora cluster's writer).
  2. On Connectivity & security, copy the Endpoint and Port.
postgres://myuser:YOUR-PASSWORD@mydb.abc123xyz.eu-central-1.rds.amazonaws.com:5432/postgres?sslmode=require

2. Let pgquery reach it

  • Private database (most setups): run pgquery inside the same VPC, for example on an EC2 instance or as an ECS task, and connect to the endpoint from there.
  • Publicly accessible database: add an inbound rule to the instance's security group for port 5432 from the IP address pgquery runs on. Never open it to 0.0.0.0/0.

The hosted app at pgquery.dev can reach databases on the public internet. For a database inside a private network, run pgquery yourself next to it:

docker run -p 54280:54280 ghcr.io/hxndrik/pgquery

Common errors

If you seeDo this
i/o timeout (or: context deadline exceeded)The security group or network blocks the connection. Allow port 5432 from pgquery’s address, or run pgquery inside the VPC.
no pg_hba.conf entry for host … no encryptionThe server requires SSL. Add sslmode=require to the connection string.
password authentication failedCheck the user and password; for IAM authentication, generate a token and use it as the password (tokens expire after 15 minutes).

Not supported (yet)

pgquery has no SSH tunnel. If you normally reach RDS through a bastion host, run pgquery on that host or inside the VPC instead.

Questions

Does pgquery work with Aurora PostgreSQL?

Yes. Use the cluster writer endpoint, or a reader endpoint for read-only browsing.

Can I connect through an SSH bastion?

Not directly. Run pgquery inside the VPC or on the bastion host.

More chapters