---
title: "Deploy Postgres with PgBouncer"
description: "Add PgBouncer as a connection pooler in front of Postgres"
category: "Storage"
url: https://railway.com/deploy/postgres-with-pgbouncer
---

# Deploy Postgres with PgBouncer

Add PgBouncer as a connection pooler in front of Postgres

**[Deploy Postgres with PgBouncer on Railway](https://railway.com/template/postgres-with-pgbouncer)**

- **Creator:** Railway Templates
- **Category:** Storage
- **Total deploys:** 3

## Template content

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

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

### PgBouncer https://devicons.railway.app/postgres

- **Image:** ghcr.io/railwayapp-templates/pgbouncer:1

## Documentation

# Postgres PgBouncer

Adds [PgBouncer](https://www.pgbouncer.org/) as a connection pooler in front of your Postgres database.

## Connecting

Use `DATABASE_URL` from the **PgBouncer** service instead of connecting directly to Postgres.

For operations transaction pooling can not serve (migrations, LISTEN/NOTIFY, session-level `SET`), use `DATABASE_UNPOOLED_URL` (or `DATABASE_PUBLIC_UNPOOLED_URL` over the public network) — they point straight at the database.

## Configuration

| Variable | Default | Description |
|---|---|---|
| `POOL_MODE` | `transaction` | `session`, `transaction`, or `statement` |
| `MAX_CLIENT_CONN` | `1000` | Max total client connections |
| `DEFAULT_POOL_SIZE` | `20` | Server connections per db/user pair |


## 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/postgres-with-pgbouncer
