If you want full control over cost, performance and where your data lives, learning to deploy Next.js on a VPS is one of the most useful skills a UK developer can pick up in 2026. Managed platforms like Vercel and Netlify are wonderful for getting started, but as traffic grows the bills climb and your infrastructure choices narrow. In this guide we compare three practical, production-ready ways to run Next.js on a UK VPS β PM2, Docker and Coolify β and show how to put Nginx and HTTPS in front of any of them.
What Is Next.js in Production?
Next.js is a React framework that supports server-side rendering (SSR), static generation, API routes and the App Router. In development you run next dev, but that server is not built for real traffic. For production you compile the app with next build and then serve it with next start, which launches a Node.js server listening on port 3000 by default. That single process handles SSR, route handlers and serves your pre-built pages.
There are two other output modes worth knowing. The standalone output (set output: 'standalone' in next.config.js) produces a minimal, self-contained server folder with only the dependencies your app actually uses β ideal for slim Docker images. A static export emits plain HTML and is only suitable for fully static sites with no SSR or API routes. Most real apps use the default Node server or standalone output.
Why Deploy Next.js on Your Own VPS
Managed hosts remove operational work, and that convenience is genuinely valuable early on. But there are solid reasons a growing team looks for a Vercel alternative and moves onto its own server.
- Predictable cost at scale β a fixed monthly VPS price beats per-seat, per-function and bandwidth-metered billing once traffic is steady.
- Full control β run background jobs, a database, a cache and cron on the same box, with any Node.js version and system packages you like.
- UK data residency β keep customer data on UK soil, which matters for compliance and for clients who ask where their data lives.
- No vendor lock-in β your deployment is portable across any provider.
The trade-off is honest: you become responsible for patching, monitoring and scaling the server yourself. For many UK startups and agencies that control is well worth it, especially on a UK VPS close to their users. A single node from a provider such as UK Speed comfortably runs a small to mid-sized Next.js app.
What You Need to Deploy Next.js on a VPS
Before you begin, make sure you have the essentials in place. A small Next.js app runs happily on roughly 1β2GB of RAM; SSR-heavy apps, or those doing builds on the same box, want 2β4GB or more, since next build itself is memory-hungry.
- A UK VPS running a recent Ubuntu or Debian LTS release.
- A non-root sudo user and hardened SSH β see our guide to hardening SSH on a Linux VPS.
- Node.js (an LTS version, installed via nvm) for the PM2 route, or Docker for the container routes.
- A domain name with DNS pointed at your server’s IP, ready for HTTPS.
PM2 vs Docker vs Coolify
All three approaches end with a Next.js server running on port 3000 behind a reverse proxy. They differ in effort, isolation and day-to-day developer experience. The table below summarises the trade-offs.
| Method | Setup effort | Isolation | Zero-downtime | Best for |
|---|---|---|---|---|
| PM2 | Low β bare Node.js, no containers | None (shares host) | Yes (pm2 reload) | Single app, minimal moving parts |
| Docker | Medium β write a Dockerfile | High (containerised) | Yes (rolling with Compose) | Reproducible, portable deploys |
| Coolify | Low ongoing β one-time install | High (containers under the hood) | Yes (built-in) | Best DX, Git push-to-deploy |
In short: PM2 is the leanest, Docker is the most portable and reproducible, and Coolify gives you the smoothest ongoing workflow. We compare the self-hosted PaaS route in more depth in our Coolify vs Vercel vs Netlify piece.
How to Build Next.js for Production
Every method starts from the same production build. Pull your code onto the server (or your CI runner), install dependencies deterministically with npm ci, then run next build. The reproducible install matters β it uses your lockfile exactly.
git clone https://github.com/your-org/your-app.git
cd your-app
npm ci
npm run build # runs next build
npm run start # runs next start on port 3000
For the Docker route especially, enable standalone output so the runtime image only ships what it needs:
// next.config.js
module.exports = {
output: 'standalone',
};
If any step is unclear, the official documentation is excellent β see the official Next.js deployment docs for the full self-hosting reference.
How to Deploy Next.js with PM2
PM2 is a process manager for Node.js that keeps your app running, restarts it on crashes and survives reboots. It is the simplest way to deploy Next.js: no containers, just Node and a small tool. After building, start the app under PM2 and give it a name.
npm ci && npm run build
pm2 start "npm run start" --name myapp
# or run the binary directly:
# pm2 start node_modules/.bin/next --name myapp -- start
pm2 save # persist the current process list
pm2 startup # generate the boot service, then run the printed command
To ship a new version with zero downtime, rebuild and then reload β PM2 restarts workers gracefully so requests are not dropped:
git pull && npm ci && npm run build
pm2 reload myapp
Getting PM2 to reliably relaunch after a server reboot has one or two gotchas; our guide to PM2 auto-restart on a UK VPS walks through pm2 save and pm2 startup in detail.
How to Deploy with Docker and Coolify
Docker packages your app and its runtime into an image that runs identically on any machine. A multi-stage Dockerfile keeps the final image tiny by building in one stage and copying only the standalone output into the runner.
# deps
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci
# build
FROM node:20-alpine AS build
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# runner
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]
Build and run it, or manage it with Docker Compose alongside a database and cache. For a full multi-service pattern, see our Docker Compose on a UK VPS walkthrough.
docker build -t myapp .
docker run -d --name myapp -p 3000:3000 --env-file .env myapp
Coolify is a self-hosted PaaS you install on the VPS once β think Heroku or Vercel, but on your own hardware. You connect a Git repository through its web UI, and it builds and deploys your Next.js app automatically on every push, provisions HTTPS for you and manages containers behind the scenes. It offers the best ongoing developer experience of the three, and pairs neatly with a self-hosted CI/CD pipeline if you want tests to run before each deploy.
Configure Nginx as a Reverse Proxy
Whichever method you choose, your Next.js server listens on localhost:3000. You should not expose that directly. Instead put Nginx (or Caddy) in front on ports 80 and 443 to terminate TLS, forward requests and set the correct proxy headers. Note that Coolify handles this layer for you automatically; the block below is for the PM2 and Docker routes.
server {
listen 80;
server_name example.co.uk;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
gzip on;
gzip_types text/css application/javascript application/json;
}
Add free HTTPS with Let’s Encrypt via Certbot, which edits the config to listen on 443 and auto-renews:
sudo certbot --nginx -d example.co.uk
Handling Environment Variables Safely
Store configuration in a .env file or your platform’s environment settings, never in the repository. In Next.js, variables prefixed with NEXT_PUBLIC_ are baked into the client bundle and visible in the browser, so use that prefix only for non-secret values. Everything else β API keys, database URLs β stays server-side. Remember that public variables are read at build time, so rebuild after changing them.
Choose the Right Deployment Method
There is no single best answer β the right choice depends on your team and workload:
- Choose PM2 if you run a single app, want the least overhead and are comfortable managing Node.js directly on the server.
- Choose Docker if reproducibility and portability matter, you run multiple services, or you want your local, CI and production environments to match exactly.
- Choose Coolify if you want a Vercel-like push-to-deploy experience with automatic HTTPS and a web UI, without hand-rolling the plumbing.
Many teams start with PM2 for its simplicity, then graduate to Docker or Coolify as their needs grow. All three run comfortably on a modest UK VPS, and because the underlying Node.js build is identical, switching between them later is straightforward rather than a rewrite.
Conclusion
You can deploy Next.js on a UK VPS in production with any of these three approaches, and each is a legitimate Vercel alternative that gives you cost control, full ownership of your infrastructure and UK data residency. PM2 keeps things lean, Docker makes deploys portable and reproducible, and Coolify delivers the smoothest ongoing experience β all sitting behind an Nginx reverse proxy with free HTTPS.
Pick the method that matches your team’s comfort level today; you can always migrate later, because a VPS keeps your options open.
- Provision a UK VPS with Node.js or Docker installed and hardened SSH.
- Run
next build, then start your app under PM2, Docker or Coolify. - Put Nginx in front and add HTTPS with Let’s Encrypt.
- Set your environment variables securely and enable zero-downtime reloads.
Deploy your Next.js app on a UK Speed VPS
Get the CPU, RAM and full root access to build and run Next.js with PM2, Docker or Coolify on high-performance AMD EPYC hardware, hosted in the UK with predictable pricing.
