Postgres installed on your computer
Start pgquery and point it at host.docker.internal:
docker run -p 54280:54280 --add-host=host.docker.internal:host-gateway ghcr.io/hxndrik/pgquery
postgres://postgres:YOUR-PASSWORD@host.docker.internal:5432/postgres
On Docker Desktop (macOS, Windows) host.docker.internal works without the --add-host flag; on Linux the flag adds it.
Postgres in Docker Compose
Put both in one Compose file and use the service name as the host:
services:
db:
image: postgres:17
environment:
POSTGRES_PASSWORD: example
pgquery:
image: ghcr.io/hxndrik/pgquery
ports:
- "54280:54280"
postgres://postgres:example@db:5432/postgres
Common errors
| If you see | Do this |
|---|---|
dial tcp 127.0.0.1:5432: connect: connection refused | localhost inside the container is the container. Use host.docker.internal or the Compose service name. |
dial tcp …:5432: connect: connection refused (with host.docker.internal) | Postgres only listens on 127.0.0.1. Set listen_addresses = '*' in postgresql.conf (or start the container with -p 5432:5432) and allow the Docker network in pg_hba.conf. |
this server does not connect to private or local addresses | You are on a public instance (like pgquery.dev) that blocks private addresses. Run pgquery yourself to reach local databases. |