---
title: "Deploy Prefect | (Just Updated) Workflow Orchestration, Server + Worker + Postgres, Login Protected"
description: "Self-hosted Prefect: server, worker, Postgres, login protected"
category: "Automation"
url: https://railway.com/deploy/prefect-or-just-updated-workflow-orchest
---

# Deploy Prefect | (Just Updated) Workflow Orchestration, Server + Worker + Postgres, Login Protected

Self-hosted Prefect: server, worker, Postgres, login protected

**[Deploy Prefect | (Just Updated) Workflow Orchestration, Server + Worker + Postgres, Login Protected on Railway](https://railway.com/template/prefect-or-just-updated-workflow-orchest)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/prefect-or-just-updated-workflow-orchest/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Automation

## Template content

### prefect-worker

- **Image:** prefecthq/prefect:3.8.8-python3.12@sha256:57e02b3f63d663e02b06d4127362ea48d92d4b361fbd96c8ba8f01e5702755f4
- **Start command:** `/bin/sh -c 'export PREFECT_API_URL="http://${PREFECT_HOST}:8080/api" PREFECT_API_AUTH_STRING="admin:${PREFECT_PASSWORD}"; exec prefect worker start --pool default --type process'`

### postgres

- **Image:** postgres:18
- **Start command:** `/bin/sh -c 'export POSTGRES_DB=prefect; exec docker-entrypoint.sh postgres'`

### prefect

- **Image:** prefecthq/prefect:3.8.8-python3.12@sha256:57e02b3f63d663e02b06d4127362ea48d92d4b361fbd96c8ba8f01e5702755f4
- **Start command:** `/bin/sh -c 'export PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://postgres:${POSTGRES_PASSWORD}@${PG_HOST}:5432/prefect" PREFECT_SERVER_API_AUTH_STRING="admin:${PREFECT_PASSWORD}" PREFECT_UI_API_URL="https://${PUBLIC_DOMAIN}/api"; exec prefect server start --host 0.0.0.0 --port ${PORT:-8080}'`
- **Health check:** /api/health
- **Public domain:** Yes

## Documentation

# Deploy and Host Prefect on Railway

Prefect is an open-source workflow orchestration platform: write Python flows, schedule them, retry them, and watch every run in a web dashboard. This template deploys a complete self-hosted Prefect 3 stack — API server and UI, a process worker, and a Postgres database — with the dashboard and API protected by a login generated at deploy time.

## About Hosting Prefect

The template runs three services. `prefect` is the Prefect server (API and dashboard) backed by a Postgres 18 database whose data lives on a persistent volume, so flow runs, deployments, and schedules survive redeploys. `prefect-worker` is a process worker that polls the `default` work pool over Railway's private network and executes your scheduled flow runs. The API and UI sit behind basic authentication: the username is `admin` and the password is the `PREFECT_PASSWORD` variable generated on your `prefect` service. The worker receives the same credentials automatically. To use it from your own machine, run `prefect config set PREFECT_API_URL=https:///api` and `prefect config set PREFECT_API_AUTH_STRING=admin:`.

## Why Deploy Prefect 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 Prefect 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.

- **Login protected out of the box** — most self-hosted Prefect servers expose an open API; this one generates a password at deploy.
- **Worker included** — a ready `default` process pool, so scheduled flows run without extra setup.
- **State survives redeploys** — Postgres on a volume, not SQLite on ephemeral disk.
- **No variables to fill in** — database password, login, and public URL are all wired automatically.

## Common Use Cases

- **Data pipelines** — schedule ETL and ELT jobs with retries, caching, and run history.
- **ML and AI workflows** — orchestrate training, batch inference, and evaluation runs.
- **Automation and cron replacement** — turn scripts into observable, retryable scheduled flows.

## Dependencies for Prefect Hosting

- A Postgres database (included in this template) with a volume mounted at `/var/lib/postgresql`.
- A Python environment with the `prefect` package to write and deploy flows.

### Deployment Dependencies

- [Prefect](https://github.com/PrefectHQ/prefect) — upstream project (Apache-2.0)
- [Prefect documentation](https://docs.prefect.io/) — flows, deployments, and workers
- [Postgres](https://www.postgresql.org/) — the database backing the server


## 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/prefect-or-just-updated-workflow-orchest
