Payload CMS deployment: how to deploy with Docker, Vercel, Coolify or Cloudflare

Idea Labz · Nov 25, 2026 · 11 min read

Your Payload project runs on your laptop, and you know where it’s going. If you haven’t picked a host, where to host Payload compares the options first.

As of 24 November 2026, the latest stable release is Payload 3.94.1, published on 20 November. It needs Node.js 22.23.5, 24.22.3 or 26.13.1 or later in each line, and Next.js 16.4.5 or later on the 16 line (payload and @payloadcms/next 3.94.1). These floors can move inside a major, and our guide to Payload versions tracks them by release.

This guide covers what every deployment needs, migrations, each route, staging and rollbacks, and how we deploy our own builds.

  • What does every Payload deployment need?
  • How do you run Payload migrations on deploy?
  • How to deploy Payload with Docker
  • A production Docker Compose file for Payload and Postgres
  • How to deploy Payload on Vercel
  • How to deploy Payload on a VPS with Coolify
  • How to deploy Payload on Cloudflare Workers
  • Staging, preview environments and rollbacks
  • How we deploy our builds
  • Frequently asked questions
  • What to do next

What does every Payload deployment need?

Every Payload deployment needs a Node.js version Payload accepts, a production build, a start command, a reachable database and its environment variables on the host. Since Payload 3 runs inside Next.js, the build is the template’s build script (next build) and the start is next start, or node server.js when you build Next.js’s standalone output (Payload’s deployment docs). A website built as a second Next.js app deploys separately, so choosing one app or two sets how many deployments you run.

A Payload project usually needs these variables, named as in Payload’s templates and docs:

VariableWhat it doesWhen it’s read
PAYLOAD_SECRETSigns logins and API key lookups. Payload won’t start without it.Runtime, payload migrate, and build if pages call Payload
DATABASE_URLThe database connection string. The Vercel Postgres template calls it POSTGRES_URL.Runtime, and build if it migrates or prerenders
PAYLOAD_CONFIG_PATHTells the payload command where your config is, when tsconfig.json doesn’tWherever you run payload migrate
NEXT_PUBLIC_*Values the browser needs, such as your site’s URLBuild, because Next.js writes them into the bundle
BLOB_READ_WRITE_TOKENVercel Blob storage, if you use its adapterRuntime
CRON_SECRETLets Vercel Cron call Payload’s jobs endpointRuntime

For example, a recruitment agency’s job board in Dubai runs Payload 3.94.1 on Postgres, with job listings and candidates’ CV uploads. On Vercel it sets PAYLOAD_SECRET and DATABASE_URL per environment, plus the Blob token, because the CVs need storage that survives a deploy. Our hosting guide’s runtime table shows how jobs, migrations and uploads differ between serverless and a long-running server.

How do you run Payload migrations on deploy?

On Postgres or SQLite, you create migrations on your machine, commit them, and run them against the production database before the new code serves traffic. On MongoDB, schema changes don’t need them. Payload gives you two places to run them on deploy (Payload’s migration docs):

  1. In the build, with payload migrate && pnpm build as the build command. Payload’s Postgres templates ship this as their ci script, and a failed migration stops the deploy.
  2. At start-up, by passing your migrations to the database adapter as prodMigrations. Payload runs them when it connects in production, which suits a long-running server.
// src/payload.config.ts
import { postgresAdapter } from '@payloadcms/db-postgres'
import { migrations } from './migrations'

export default buildConfig({
  // ...the rest of your config
  db: postgresAdapter({
    pool: { connectionString: process.env.DATABASE_URL || '' },
    prodMigrations: migrations,
  }),
})

payload migrate:create writes src/migrations/index.ts, which exports that list. In a Next.js app, Payload connects the first time code loads it, so prodMigrations run on the first request, or during next build if pages read Payload while prerendering (payload@3.94.1, getPayload and init).

Three things in the 3.94.1 code shape the setup (@payloadcms/drizzle migrate):

  • A dev push makes payload migrate ask first. When a dev server pushes schema changes to a Postgres or SQLite database, Payload records the push in the migrations table. If payload migrate finds that record, it asks whether to continue before running anything, and answering no ends the command with a success code, so the ci script goes on to build unmigrated. Keep development on its own database, and production never has the record.
  • The migrate step takes no lock of its own. It reads which migrations have run, then runs the rest. Two instances that start together can both read the table before either records a new migration, so start one instance first, or run payload migrate once as its own step.
  • On Postgres, each migration runs in its own transaction. A failed one rolls back its own changes and the command exits with an error, while the ones before it in the same run stay applied. D1 opens no transaction unless you configure one.

For example, the job board adds a salary range field to its jobs. The developer runs pnpm payload migrate:create add-salary-range, commits the file with the field, and the next deploy runs it before the new code goes live. Our guide to Payload migrations covers the commands, and the database guide covers the adapters.

Write each migration so the previous release still works with it, adding fields first and removing old ones in a later release.

How to deploy Payload with Docker

Payload’s blank, website and Postgres templates share one multi-stage Dockerfile on node:22.23.5-alpine, which builds the app and runs node server.js from Next.js’s standalone output as an unprivileged user.

The Dockerfile expects three steps before you build, and Payload’s docs list the first.

First, turn on standalone output. The Dockerfile copies .next/standalone, which Next.js writes only when next.config sets output: 'standalone', and its first line and Payload’s deployment docs both say to set it. At 3.94.1, none of the blank, website or ecommerce templates’ next.config.ts files sets it.

// next.config.ts
const nextConfig: NextConfig = {
  output: 'standalone',
  // ...the template's existing settings
}

Second, check for a public/ folder. The Dockerfile copies one, its comment says to remove that line if you have none, and the blank template has none at 3.94.1.

Third, add a .dockerignore. No template ships one at 3.94.1, and the Dockerfile’s COPY . . copies the whole project folder into the build. When next build in Next.js 16.4.6 loads a .env or .env.production file, it copies that file into the standalone output, and server.js reads it as defaults at run time (Next.js output docs). So a .env in the folder you build from ends up in the image. Add this .dockerignore next to the Dockerfile:

.env
.env.*
!.env.example
node_modules
.next
.git

Pass secrets when the container starts instead. The job board’s developer, for example, keeps a development PAYLOAD_SECRET in a local .env, which the .dockerignore keeps out of the image. NEXT_PUBLIC_ values still have to be there at build time, since they’re compiled into the browser code.

If your pages read from Payload while they’re prerendered, next build needs the database. Build with next build --experimental-build-mode compile to skip prerendering, as Payload’s guide to building without a database shows, and pages render on request.

Raise the image’s node:22.23.5-alpine tag whenever Payload raises its Node.js floor.

Payload ships no health endpoint, so add a route your host can call, returning 200 only when Payload reaches its database:

// src/app/health/route.ts
import configPromise from '@payload-config'
import { getPayload } from 'payload'

export const dynamic = 'force-dynamic'

export const GET = async () => {
  const payload = await getPayload({ config: configPromise })
  await payload.count({ collection: 'users' })
  return Response.json({ ok: true })
}

Because it loads Payload, a host that waits on this check runs any prodMigrations before it sends traffic. By default, Payload writes uploads on disk to a folder named after the collection, relative to the working directory (the website template sets its own folder), and the Dockerfile’s runner stage runs as the nextjs user. Create that folder in the Dockerfile, owned by nextjs, and mount a volume on it, or use a storage adapter.

A production Docker Compose file for Payload and Postgres

The docker-compose.yml in Payload’s templates runs pnpm dev on your mounted project folder, for development, as Payload’s docs say. For production, a compose.yaml runs the image you built, next to a database it waits for:

services:
  payload:
    build: .
    restart: unless-stopped
    ports:
      - '3000:3000'
    env_file: .env
    depends_on:
      postgres:
        condition: service_healthy
  postgres:
    image: postgres:18
    restart: unless-stopped
    environment:
      POSTGRES_USER: payload
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: payload
    volumes:
      - pgdata:/var/lib/postgresql
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U payload -d payload']
      interval: 10s
      retries: 5
volumes:
  pgdata:

The server’s .env holds PAYLOAD_SECRET, POSTGRES_PASSWORD and a DATABASE_URL that names the postgres service as its host. Compose waits for pg_isready to pass before it starts Payload (Docker’s startup order docs).

The Postgres major is pinned because the data path changed. From PostgreSQL 18, the official image keeps its data under /var/lib/postgresql, and 17 and earlier under /var/lib/postgresql/data (the image’s docs). On 17 and earlier, a volume on the wrong path loses its data when the container is recreated; 18 won’t start with a volume on the old path.

The runner stage holds only Next.js’s standalone output, so run migrations with prodMigrations, or run payload migrate once from a container built from the Dockerfile’s builder stage, which holds the whole project. The job board, for example, runs one payload container behind a reverse proxy, with prodMigrations on and CVs in object storage.

How to deploy Payload on Vercel

Vercel runs Payload as serverless functions. Payload’s Vercel Postgres template has a deploy button that creates a Neon database and a Vercel Blob store, asks for PAYLOAD_SECRET, and builds with its ci script:

"ci": "payload migrate && pnpm build"

For your own repository, use the same build command and set variables per environment. Vercel lets you choose only the Node.js major (26.x by default, 24.x or 22.x) and applies minor and patch releases itself (Vercel’s Node.js versions).

Neon’s Vercel integration gives Production and Preview the database variables by default, and a database branch for each previewed Git branch only when you turn on Preview Branching (Neon’s Vercel integration docs). With pnpm run ci as the build command, a preview build without its own branch runs its migrations against production.

For example, the salary range work gets its own Neon branch, preview/salary-range, copied from production. The preview build runs the new migration there, and production meets it only when the branch merges.

A business’s site runs on Pro, because Vercel’s terms limit Hobby to personal or non-commercial use. A function runs for up to 300 seconds on Hobby and up to 800 on Pro (Vercel’s function limits). Uploads over Vercel’s default 4.5 MB request limit (20 MiB in a public beta) need client uploads, as our upload guide explains, and background jobs need a scheduled call, such as Vercel Cron, which our jobs guide sets up.

How to deploy Payload on a VPS with Coolify

Coolify deploys the same Dockerfile on your own server, with Git push deploys and certificates. Point an application at your repository with the Dockerfile build pack, add Postgres as a Coolify database in the same project, and set its variables.

Coolify makes each new variable available to both the build and the running container. NEXT_PUBLIC_ values need the build, and Coolify’s docs advise runtime only for a secret the app reads after it starts, such as PAYLOAD_SECRET (Coolify’s environment variable docs).

Set a health check on the /health route. Coolify runs HTTP checks from inside the container, so the image needs curl or wget (Coolify’s health check docs). The template’s Alpine image carries BusyBox wget.

With a health check, Coolify overlaps the two containers. It starts the new one, waits for its check to pass, and only then stops the old one (Coolify’s rolling updates). Without a check, a container that has started counts as ready, even while Payload is still connecting. Rolling updates don’t run for Docker Compose applications, or with a port published on the host, which two containers can’t share.

For example, the job board’s second copy runs on a client’s own VPS, where the old container keeps serving after the new one has run the salary range migration, so the old code must work with the new column.

How to deploy Payload on Cloudflare Workers

Payload’s Cloudflare template runs on Workers with D1, Cloudflare’s SQLite database, for data and R2 for files, through bindings in wrangler.jsonc. Once its D1 database and R2 bucket exist, deploying takes three commands:

pnpm wrangler login
pnpm payload migrate:create
pnpm run deploy

pnpm run deploy runs payload migrate against the remote D1 database, optimises it, then builds and deploys the Worker with OpenNext’s Cloudflare adapter.

The template’s README says it “can only be deployed on Paid Workers right now due to size limits”, citing a 3 MB bundle limit. Cloudflare removed that limit on 4 September 2026, and every plan now allows a 64 MiB uncompressed Worker (Cloudflare’s changelog). The limit that matters on the Free plan now is 10 ms of CPU time per request, against up to 5 minutes on Workers Paid (30 seconds by default), which starts at $5 a month (Cloudflare’s Workers limits).

The README also says Workers can’t run sharp, so Payload can’t resize images, GraphQL isn’t guaranteed, and logs stay off until you turn them on. So a job board that crops candidates’ photos fits Vercel or a server better, and our hosting guide covers which projects suit Cloudflare.

Staging, preview environments and rollbacks

Each environment needs its own database, development included, since a dev server changes the schema of any database it’s given.

On Vercel, staging is a custom environment on Pro and Enterprise, or on any plan a preview branch such as staging with its own domain and branch-scoped variables (Vercel’s environments docs).

Give each environment its own PAYLOAD_SECRET, and keep it stable, because changing it signs everyone out and stops existing API keys from matching.

A rollback on any host restores code only, Vercel’s Instant Rollback included. payload migrate:down reverses the last batch, but a migration that dropped a column can’t bring its data back. Take a database backup or branch before a release that changes the schema.

The job board’s staging, for example, is a Vercel preview branch named staging with its own Neon branch, where the agency checks releases.

How we deploy our builds

As of our project template v2.13.1 (17 November 2026, on Payload 3.93.0), projects made from it deploy to Vercel, with Postgres on Neon and media on Vercel Blob. That’s the default, and depending on what a project needs, we often deploy it other ways. The template also includes a baseline Dockerfile and Compose file for the backend.

Where a client reviews releases before production, the project gets a staging environment with its own database, which never sends real email and won’t start with a live payment key. Preview builds never get the production database. The production build runs Payload’s migrations first, so a failed migration stops the build and the previous deployment keeps serving. Before any step that could change a production database, we take a backup.

Our Payload CMS development service sets this up for your project.

Frequently asked questions

Where should I deploy Payload?

Anywhere that runs Next.js on a Node.js version Payload accepts. Our Payload hosting guide compares them by the kind of server your project needs.

What is PAYLOAD_SECRET, and what should it be?

Payload signs logins and API key lookups with it and won’t start without it. Use a long random string per environment, set in your host’s settings.

Can I deploy Payload CMS on Vercel for free?

Only for personal or non-commercial projects, which is what Vercel’s terms allow on Hobby. Hobby functions stop at 300 seconds, and cron jobs run once a day at most.

Does Payload CMS have a Docker image?

No. Build your own from the Dockerfile in Payload’s templates.

What do I need before building Payload’s Dockerfile?

Set output: 'standalone' in next.config, as Payload’s docs say, add a public/ folder or remove the line that copies it, and add a .dockerignore for your .env files. If pages read Payload while prerendering, the build also needs a database.

How do I run Payload migrations in production?

Run payload migrate before the build on serverless hosts, or pass your committed migrations to the adapter as prodMigrations on a long-running server.

Can I deploy Payload on Cloudflare’s free plan?

Bundle size no longer blocks it, since every plan allows 64 MiB. Test against the Free plan’s 10 ms of CPU per request. Payload’s template still recommends Workers Paid.

What to do next

Before each deploy, check that the host’s Node.js meets Payload’s floor, that every environment has its own variables and database, that migrations run before new code goes live, that previews can’t reach production, and that your host has a health check to wait on. If the project isn’t built yet, start it from Payload’s templates first.

References

All links checked and active as of 24 November 2026.

READY TO MAKE A REAL CHANGE?

Let's build it together