How to Deploy a Next.js App on Hetzner VPS With Docker & Caddy (Step-by-Step 2026)
Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

Deploying Next.js on Vercel is frictionless, but as your web traffic grows, serverless invocation limits and bandwidth fees can quickly escalate into hundreds of dollars per month.
By deploying your Next.js application inside a containerized Docker environment on a €4/month Hetzner Cloud VPS behind Caddy Server, you get:
- Blazing-fast performance with persistent memory caching.
- Zero cold starts for Server-Side Rendered (SSR) routes.
- Automated SSL encryption with Let's Encrypt.
- Complete control over background worker threads.
Here is the complete step-by-step production deployment guide for 2026.
Step 1: Configure next.config.ts for Standalone Output
In your Next.js project root, enable standalone build tracing in next.config.ts:
Step 2: Create a Multi-Stage Dockerfile
Create a Dockerfile in your repository. This multi-stage build compiles your TypeScript assets and generates a minimal 100MB production runner image:
Step 3: Configure docker-compose.yml and Caddyfile
In your project directory on your Hetzner VPS, create a docker-compose.yml file:
Now create your Caddyfile in the same folder:
Point your domain's DNS A record to your Hetzner VPS IPv4 address, run docker compose up -d --build, and your Next.js application will be live over HTTPS in seconds!
Frequently Asked Questions
Setting output: 'standalone' in next.config.ts automatically traces your imports and bundles only the minimal node_modules required, shrinking production Docker image size from 1.2 GB to under 120 MB.
Caddy automatically issues, configures, and renews Let’s Encrypt SSL/TLS certificates with zero configuration—you just specify your domain name in a 3-line Caddyfile.
Using restart: always in your docker-compose.yml file ensures Docker automatically launches your Next.js application whenever the VPS restarts.
The CX22 instance (2 vCPUs, 4 GB RAM) for ~€3.79/month is ideal. It provides ample headroom for Next.js Server-Side Rendering (SSR) and image optimization.

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.


