StackPilot

The Cheapest Way to Run a Node.js API in Production

By The StackPilot Team 8 min read

Some links on this page are affiliate links. If you sign up through them we may earn a commission at no extra cost to you. We only link to services we have actually used, and commission never decides what we recommend.

You have a Node API that needs to stay up, and every hosting comparison you open is written by someone selling the host. The invoice is the easy part to compare. What actually decides the bill is how many hours a month you spend on kernel patches, TLS renewals, and the 2am page when the process manager gives up.

This is the shortlist I'd hand to someone shipping a real API, ranked by total cost rather than sticker price.

Quick verdict

For most people running a Node.js API that other people depend on, Cloudways is the cheapest option once you price your own time — you get a managed stack on DigitalOcean, Vultr, or Linode, TLS and OS maintenance handled, and you deploy your app from Git. The tradeoff is real: you pay a managed markup per server, and you still own your Node process. If the API is a side project, a demo, or you genuinely enjoy sysadmin work, skip straight to option two — a raw VPS with Caddy and systemd is the cheapest invoice you can get.

What you are actually choosing between

OptionCost shapeOps burden and lock-in
Raw VPS + Caddy + systemdCheapest tier; single-digit to low double-digit dollars per month, billed hourlyYou own everything: OS updates, TLS, backups, monitoring. No lock-in — it's just Linux.
Cloudways (managed on DO/Vultr/Linode)Mid; roughly the underlying server price plus a managed markup, per serverThey handle OS, stack, TLS, and snapshots. You handle your app and its process. Low lock-in — the app is portable.
PaaS (Render, Railway, Fly)Mid to premium; scales with instance count and always-on requirementsNear-zero ops. Highest convenience, and the most opinionated about how your app must be built.
Docker Compose on a VPSCheapest tier plus your time; same server cost as option oneModerate. You get reproducibility and multi-service deploys, but you now maintain Docker, images, and volumes.
Serverless functionsPer-request; near-zero at idle, unpredictable under steady loadLowest ops, highest cold-start and vendor lock-in risk.

The shortlist, ranked

1. Cloudways — best total cost for a production API

This is the pick when the API has users and you don't want to be the on-call sysadmin. Cloudways rents capacity from DigitalOcean, Vultr, Linode, and a couple of the bigger clouds, then wraps it in a control panel that handles the parts you'd otherwise do by hand.

The setup, roughly:

  1. Pick your infrastructure provider and server size. Start at the smallest size that fits your Node heap plus headroom — a 1GB box runs a small API fine, but budget for 2GB once you add a reverse proxy, logging, and a build step.
  2. Create a Node.js application on that server. The panel provisions the stack; check the current docs for which Node version and process manager the stack ships with, since that changes.
  3. Point your domain at the server IP and issue Let's Encrypt through the panel. Renewal is automatic — this alone removes a recurring failure mode.
  4. Deploy from Git. Connect the repo, set the branch, and use the panel's deployment hook so a push pulls the new code. Run your build step and restart the process.
  5. Set up the cron-based backup and take a snapshot before your first real deploy. Snapshots are the fastest rollback you'll have.

What you're buying is not speed — a raw droplet is the same hardware. You're buying the absence of a Saturday spent debugging why certbot didn't renew. For a two-person team shipping product, that trade is almost always correct.

2. Raw VPS with Caddy and systemd — cheapest invoice, period

If you want the lowest possible monthly number, rent a small VPS directly from Hetzner, DigitalOcean, Vultr, or Linode and run the thing yourself. Hetzner is the price leader in most regions; DigitalOcean and Vultr have more locations and better docs. Prices move, so check the current pricing page rather than trusting any blog post, including this one.

Two files do most of the work. Caddy handles TLS and reverse proxying:

api.example.com {
    encode gzip
    reverse_proxy 127.0.0.1:3000
}

And systemd keeps the process alive across crashes and reboots:

[Unit]
Description=node api
After=network.target

[Service]
User=deploy
WorkingDirectory=/srv/api
ExecStart=/usr/bin/node dist/server.js
Restart=always
RestartSec=3
Environment=NODE_ENV=production
EnvironmentFile=/srv/api/.env

[Install]
WantedBy=multi-user.target

Then systemctl enable --now api. Do not run the process as root, and do not put secrets in the unit file — use the EnvironmentFile.

The catch is everything else: unattended-upgrades, a firewall, log rotation, a backup job you've actually tested, and an uptime check that texts you. That's a weekend of setup and a few hours a month forever. It's cheap if your time is free. It isn't, usually.

3. PaaS — cheapest to ship today

Render, Railway, and Fly.io all get a Node API from repo to HTTPS URL in minutes. If you're validating an idea this week, this is the right answer and the cost is irrelevant at that stage.

The reason it's third and not first: the cost shape. You're billed per instance and per always-on service, and a production API needs to be always on. Two environments plus a worker add up faster than one VPS. You also inherit their build system, their networking model, and their definition of a healthy process. Moving off later is a day of work, not an afternoon.

Pick this if you're pre-revenue. Move to option one when you have paying users and the bill starts to look like a mortgage.

4. Docker Compose on a VPS — when the API isn't alone

The moment you need Postgres, Redis, and a background worker on the same box, hand-managed systemd units get messy. Compose gives you one file that describes the whole stack and one command to bring it up.

You're still on a cheap VPS, so the server cost is the same as option two. You've traded some of that savings for image builds, volume backups, and the discipline of pinning versions. Use a managed database if you can afford it — running Postgres in a container on the same disk as your API is how people lose data.

5. Serverless functions — only for spiky or near-zero traffic

If your API gets a handful of requests an hour, or bursts hard twice a day and idles otherwise, per-request billing genuinely wins. A webhook receiver or an internal tool is a good fit.

A steady-traffic API is a bad fit. You pay per invocation and per duration, cold starts add latency you can't tune away, and the code has to be written around the platform's constraints. Do the arithmetic on your actual request volume before committing.

Where this falls short

Cloudways has real drawbacks and you should hear them before you buy. Billing is per server, so a staging environment costs the same as production — teams often skip staging to save money and then regret it. There's no autoscaling: when traffic spikes you resize the server and wait, or clone and put a load balancer in front, which is manual work. The panel is functional rather than fast, and support runs on tickets, so a hard outage is not a live chat. Their Node.js tooling is also less mature than their PHP story — you'll be managing your own process manager and deploy hooks more than you would on a Node-first PaaS. If you need containers, Kubernetes, or multi-region failover, this is the wrong product entirely.

And if you're running something that must not go down — payments, auth for a large user base — none of the cheap options are right. Pay for a managed database, a load balancer, and two servers in different zones. That's a different budget and a different article.

Finally: if you can't commit to checking on the box at least monthly, don't take the raw VPS route. An unpatched server is more expensive than a managed one.

FAQ

Is a cheap VPS enough to run a Node.js API?

For low to moderate traffic, yes. A 1–2GB VPS runs a single Node process comfortably; Node is single-threaded, so beyond one core you're usually better off scaling vertically first and adding processes with a cluster module or multiple systemd units later. Measure before you upgrade.

Can you run Node.js on Cloudways?

Yes — Node.js is one of the application types you can provision on a Cloudways server. You get the managed OS and stack plus Git-based deployment, but you still configure your own process management and build steps. Confirm the current Node version and stack details in their docs before you migrate.

Is serverless cheaper than a VPS for a Node.js API?

Only if your traffic is genuinely sparse or bursty. At steady load, per-request and per-duration billing usually exceeds a flat monthly VPS, and you inherit cold starts. Model it against your real request count, not a hypothetical.

Do I need Docker to run a Node.js API in production?

No. A systemd unit plus a reverse proxy is a perfectly good production setup for a single service. Docker earns its keep when you have multiple services, need identical dev and prod environments, or deploy often enough that manual steps become error-prone.

Related reading: How to Set Up a Reverse Proxy with Caddy on a Linux VPS, How to Deploy a Python App Without Docker on a VPS

Bottom line

The cheapest way to run a Node.js API in production is the one that costs you the least in dollars plus hours. For most teams with real users, that's Cloudways: a managed server you don't have to patch, with TLS handled and a Git deploy, at a price close enough to raw infrastructure that the difference disappears against an hour of your time. Take the raw VPS instead if the API is a hobby or you enjoy the work — it is genuinely cheaper, and the setup above is all you need.

Today's step: write down what your API actually needs — memory, whether it needs a database on the same box, and how bad an hour of downtime is. That answer picks your row in the table above.

Try Cloudways
Managed hosting on top of DigitalOcean/Vultr/Linode.

Check current pricing