---
title: "Deploy PgDog"
description: "PgDog 0.1 Postgres connection pooler and load balancer, with Postgres."
category: "Storage"
url: https://railway.com/deploy/pgdog-1
---

# Deploy PgDog

PgDog 0.1 Postgres connection pooler and load balancer, with Postgres.

**[Deploy PgDog on Railway](https://railway.com/template/pgdog-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/pgdog-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Storage

## Template content

### pgdog https://github.com/pgdogdev.png

- **Image:** ghcr.io/pgdogdev/pgdog:v0.1.59
- **Start command:** `sh -c 'printf "[general]\nhost = \"::\"\nport = 6432\nhealthcheck_port = 8080\ndefault_pool_size = %s\n\n[admin]\nname = \"admin\"\nuser = \"admin\"\npassword = \"%s\"\n\n[[databases]]\nname = \"%s\"\nhost = \"%s\"\nport = %s\ndatabase_name = \"%s\"\n" "$PGDOG_POOL_SIZE" "$PGDOG_ADMIN_PASSWORD" "$PGDATABASE" "$PGHOST" "$PGPORT" "$PGDATABASE" > /tmp/pgdog.toml && printf "[[users]]\nname = \"%s\"\npassword = \"%s\"\ndatabase = \"%s\"\n" "$PGUSER" "$PGPASSWORD" "$PGDATABASE" > /tmp/users.toml && exec pgdog --config /tmp/pgdog.toml --users /tmp/users.toml run'`
- **Health check:** /

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

## Documentation

# Deploy and Host PgDog on Railway

PgDog is a modern PostgreSQL connection pooler, load balancer and sharding proxy written in Rust. Applications connect to it like a normal Postgres server, and it multiplexes many client connections onto a small pool of server connections with transaction pooling, health checks and failover. It is a newer alternative to PgBouncer.

## About Hosting PgDog

This template deploys PgDog v0.1.59 from the official image in front of a Railway Postgres database. The start command writes the pooler and user config from Railway references, so the database and credentials are wired up automatically, with a pool of 20 server connections. Apps connect to PgDog over the private network on port 6432 with the normal Postgres credentials, and external clients use the Railway TCP proxy. An admin database with its own generated password shows pools and statistics. PgDog keeps no state, so it needs no volume and fits the Hobby plan.

## Common Use Cases

- Handling many short-lived connections from serverless functions and autoscaled services
- Reducing Postgres memory use by pooling connections
- A foundation for read replicas, load balancing and sharding later

## Dependencies for PgDog Hosting

- `ghcr.io/pgdogdev/pgdog:v0.1.59` (official image)
- Railway Postgres (`ghcr.io/railwayapp-templates/postgres-ssl:18`) with a volume
- A Railway TCP proxy for external clients

### Deployment Dependencies

- [PgDog documentation](https://docs.pgdog.dev/)
- [PgDog releases](https://github.com/pgdogdev/pgdog/releases)
- [PgDog configuration](https://docs.pgdog.dev/configuration/)
- [Railway TCP proxy](https://docs.railway.com/reference/tcp-proxy)

### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| pgdog | `ghcr.io/pgdogdev/pgdog:v0.1.59` | private 6432; TCP proxy to 6432; health on 8080 | none |
| Postgres | Railway Postgres 18 | private only | volume |

```env
DATABASE_URL=${{pgdog.DATABASE_URL}}               # inside Railway
DATABASE_PUBLIC_URL=${{pgdog.DATABASE_PUBLIC_URL}} # external, via TCP proxy
```

```bash
psql "postgres://admin:$PGDOG_ADMIN_PASSWORD@:6432/admin" -c "SHOW POOLS"
```

| Variable | Default | Purpose |
| --- | --- | --- |
| `PGDOG_POOL_SIZE` | `20` | Server connections per pool |
| `PGDOG_ADMIN_PASSWORD` | generated | Admin database password |

Notes:

- Transaction pooling is the default: session features such as `SET` and advisory locks behave per transaction. Use `SET LOCAL` in transactions.
- The TCP proxy carries Postgres traffic without TLS from PgDog; prefer the private network.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the PgDog project or its maintainers.

## Why Deploy PgDog on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PgDog on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/pgdog-1
