---
title: "Deploy Pact Broker"
description: "Pact Broker 2.121: share and verify consumer-driven API contracts."
category: "Automation"
url: https://railway.com/deploy/pact-broker-1
---

# Deploy Pact Broker

Pact Broker 2.121: share and verify consumer-driven API contracts.

**[Deploy Pact Broker on Railway](https://railway.com/template/pact-broker-1)**

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

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

## Template content

### pact-broker https://github.com/pact-foundation.png

- **Image:** pactfoundation/pact-broker:3.0.0-pactbroker2.121.2
- **Start command:** `sh -c 'for i in $(seq 1 60); do getent hosts "$PACT_BROKER_DATABASE_HOST" >/dev/null && break; echo "waiting for $PACT_BROKER_DATABASE_HOST"; sleep 3; done; exec sh ./entrypoint.sh config.ru'`
- **Health check:** /diagnostic/status/heartbeat
- **Public domain:** Yes

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

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

## Documentation

# Deploy and Host Pact Broker on Railway

The Pact Broker stores and shares consumer-driven contracts between services. Consumer tests publish pacts, provider builds fetch and verify them, and the broker records which versions work together. Its can-i-deploy check tells your pipeline whether a release is safe, which makes integration testing of microservices faster and less brittle.

## About Hosting Pact Broker

This template runs the official `pactfoundation/pact-broker:3.0.0-pactbroker2.121.2` image with a Railway Postgres database. Basic authentication is on, with two generated accounts: `admin` can publish pacts and results, and `reader` can only read them. Anonymous visitors get a login prompt, except for the heartbeat endpoint used as the health check. On first boot, the start command waits until the database hostname resolves, then the broker creates its schema. The web UI and the HAL API share one HTTPS domain. Anonymous usage pings from the image are turned off. It fits the Hobby plan.

## Common Use Cases

- Sharing contracts between consumer and provider CI pipelines
- Gating deployments with `can-i-deploy` checks
- Triggering provider verification with webhooks when a pact changes

## Dependencies for Pact Broker Hosting

- `pactfoundation/pact-broker:3.0.0-pactbroker2.121.2` (official image)
- Railway Postgres

### Deployment Dependencies

- [Pact Broker documentation](https://docs.pact.io/pact_broker)
- [Pact Broker 2.121.2 release](https://github.com/pact-foundation/pact_broker/releases/tag/v2.121.2)
- [Pact Broker Docker image](https://github.com/pact-foundation/pact-broker-docker)

### Implementation Details

| Service | Source | Networking | Storage |
| --- | --- | --- | --- |
| pact-broker | `pactfoundation/pact-broker:3.0.0-pactbroker2.121.2` | public HTTPS | Postgres |
| Postgres | Railway Postgres | private | volume |

| Variable | Purpose |
| --- | --- |
| `PACT_BROKER_BASIC_AUTH_USERNAME` / `_PASSWORD` | Read-write account (`admin`) |
| `PACT_BROKER_BASIC_AUTH_READ_ONLY_USERNAME` / `_PASSWORD` | Read-only account (`reader`) |
| `PACT_BROKER_ALLOW_PUBLIC_READ` | `false`; set `true` to let anyone read |
| `PACT_BROKER_BASE_URL` | Public URL used in links |

Publish from CI:

```bash
pact-broker publish ./pacts --broker-base-url "$PACT_BROKER_BASE_URL" \
  --broker-username admin --broker-password "$PACT_BROKER_BASIC_AUTH_PASSWORD" --consumer-app-version "$GIT_SHA"
```

Set `PACT_BROKER_DATABASE_CLEAN_ENABLED=true` to prune old data on a schedule.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the Pact Foundation.

## Why Deploy Pact Broker 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 Pact Broker 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

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — Automate WhatsApp workflows with Evolution API, n8n, and Postgres.
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

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