Skip to main content
Website & Hosting

How to Deploy a Next.js App on Hetzner VPS With Docker & Caddy (Step-by-Step 2026)

Alex MorganAlex MorganSeptember 23, 20262 min read

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.

How to Deploy a Next.js App on Hetzner VPS With Docker & Caddy (Step-by-Step 2026) – featured image

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!

#deploy nextjs#hetzner vps#docker nextjs#caddy server#self-hosting#2026

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 - Founder & Lead Editor
Alex Morgan·Founder & Lead Editor

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.

Related Articles

Featured image for Best Cheap Dedicated Servers for Game Server Hosting in 2026Website & Hosting

Best Cheap Dedicated Servers for Game Server Hosting in 2026

Discover the best budget-friendly bare-metal dedicated servers for hosting Minecraft, Rust, Palworld, and ARK in 2026, comparing CPU single-core performance, anti-DDoS mitigation, and bandwidth.

#Dedicated Servers#Game Hosting
September 25, 20267 min read
Featured image for Best Object Storage for Media-Heavy Websites in 2026Website & Hosting

Best Object Storage for Media-Heavy Websites in 2026

Compare the best cloud object storage solutions for media-heavy websites in 2026. Detailed cost breakdown of Cloudflare R2, Backblaze B2, Wasabi, AWS S3, and DigitalOcean Spaces.

#Object Storage#Cloud Storage
September 25, 20266 min read
Featured image for Best WordPress Security Audit Tools & Plugins in 2026Website & Hosting

Best WordPress Security Audit Tools & Plugins in 2026

Compare the top WordPress security audit tools and plugins in 2026, including Wordfence, Solid Security, Patchstack, Sucuri, and WPScan CLI, with actionable hardening steps for every site.

#WordPress Security#Security Plugins
September 25, 20266 min read