Where to host a Node.js app
By Flavio
Published · Updated
Tagged: Node.js
Where to host a Node.js app in 2026: local tunnels, browser playgrounds, serverless functions, PaaS like Railway and Render, VPS providers, and bare metal.
Here are your options when you want to deploy a Node.js app and make it public, from the simplest and most constrained to the most powerful. I refreshed this list in September 2026.
For choosing across static, serverless, PaaS, and VPS in general, see Where to host your web app.
One thing to watch when comparing hosts is bandwidth pricing.
- Simplest option ever: local tunnel
- Zero configuration playgrounds
- Serverless
- PaaS
- Virtual Private Server
- Bare metal
- Which one should you pick?
- Get your app ready for any host
Simplest option ever: local tunnel
Even behind a NAT, you can serve requests right from your computer using a local tunnel. Good for quick tests and demos. Remember you are opening your machine to the public Internet.
The classic tool is ngrok. Run it with the port your app listens on:
ngrok http 3000
You get a public HTTPS URL that forwards to localhost:3000. The free account includes one static dev domain, so the URL survives restarts. Free-plan visitors click through a warning page first. Custom domains are paid.
Cloudflare Tunnel is my favorite alternative:
cloudflared tunnel --url http://localhost:3000
No account needed. You get a random trycloudflare.com URL that lives until you press Ctrl-C. Quick tunnels are capped at 200 in-flight requests and don’t support server-sent events. I cover this no-account path in the complete guide to Cloudflare Quick Tunnels. With a Cloudflare account you can create a named tunnel on your own domain, as I show in the complete guide to Cloudflare Tunnel.
localtunnel (npx localtunnel --port 3000) needs no account, but its community servers go down from time to time.
If you only need to try the app on your own phone, you don’t need a public URL: open your Mac’s dev server on your phone over Tailscale.
Zero configuration playgrounds
These run your Node.js code with no setup. Great for prototypes, not for production.
StackBlitz runs Node.js inside your browser tab, through WebContainers. Express, Fastify and Hono servers work, native modules do not.
CodeSandbox runs Node.js backends in small VMs that hibernate when idle. The free plan has a monthly budget of VM credits, check the pricing page.
Replit is the closest to real hosting. The free Starter plan lets you publish one app. It expires after 30 days (you can republish it), shows a “Made with Replit” badge, and has no custom domains.
Glitch was my favorite here, but it shut down app hosting in July 2025.
Serverless
With serverless you publish your app as functions. Each one answers on a network endpoint, and there is no server to manage or pay for when idle.
Vercel Functions run on the Node.js runtime by default. A file in the api/ folder becomes an endpoint. The Hobby plan is free within limits, and a function can run up to 5 minutes.
Netlify Functions work the same way: drop a file in netlify/functions/. The free plan is credit based, check the pricing page.
Cloudflare Workers run on Cloudflare’s own runtime, not Node.js, but with Node.js compatibility: node:crypto, node:stream, node:http and most npm packages work. It’s on by default for compatibility dates from August 4, 2026; older projects add the nodejs_compat flag. My complete Cloudflare guide goes deep.
AWS Lambda is where all this started. As of September 2026 it supports nodejs22.x and nodejs24.x, with Node.js 26 in public preview.
PaaS
PaaS stands for Platform as a Service. You point it at a Git repo, and it builds and runs a long-lived Node.js process for you.
Railway is the one I use most. Connect a GitHub repo, it detects Node.js and deploys. You pay for the CPU and memory you use on top of a small monthly plan. There is a limited free plan, check the pricing page.
Render has a free tier, with a catch: a free service spins down after 15 minutes without traffic and takes about a minute to wake up.
Fly.io runs your app in small VMs close to your users. The Free plan gives personal organizations $5 of monthly usage once you add a card (up to 3 Machines, or $1 for 7 days without a card), enough for a small always-on app. Crossing $5 switches the org to Pay As You Go and bills the whole month. You deploy with the flyctl CLI.
Heroku is the original PaaS. It no longer has a free tier. The cheapest option is the Eco plan, $5 a month as of September 2026, with dynos that sleep after 30 minutes of inactivity.
DigitalOcean App Platform deploys Node.js from a Git repo. Its free tier covers static sites only, a Node.js web service needs a paid container.
Virtual Private Server
A VPS is an empty Linux machine with root access. You install everything yourself: Node.js, a reverse proxy, HTTPS, updates.
The providers I would look at: Hetzner, DigitalOcean, Linode (now Akamai Cloud), and Vultr. Hetzner is usually the cheapest for the same specs. On DigitalOcean, doctl is the CLI for Droplets, firewalls, DNS, and App Platform.
Don’t run node server.js in a terminal and walk away. Run it as a systemd service, so it restarts on crash and at boot, or in a Docker container. My free Linux Server & Self-Hosting Handbook walks through the whole setup, from SSH to Nginx, Caddy, HTTPS and systemd.
Bare metal
The last option is a physical server. Rent one monthly from Hetzner or hourly from Vultr Bare Metal, or expose a machine at home with Cloudflare Tunnel. Everything from the VPS section applies, plus you own the hardware problems.
Which one should you pick?
Here’s how I’d decide:
- You want to show someone what’s running on your laptop right now: a local tunnel.
- You’re sketching an idea: a playground.
- You have a few API endpoints and no long-running work: serverless.
- You have a classic Express (or Fastify, or Hono) app with a database: a PaaS. This is the right answer for most apps.
- You want the lowest monthly bill for an app that’s always busy, and you don’t mind doing server admin: a VPS.
You can move later. If you follow the next section, your app runs the same way on a PaaS, a VPS or in Docker, and switching hosts is mostly a matter of setting environment variables again.
Get your app ready for any host
Most failed first deploys come down to the same few problems, whatever the host.
Read the port from PORT
A PaaS tells your app which port to listen on through the PORT environment variable. Railway and Heroku set it for you. On Render it defaults to 10000. On Fly.io, your app must listen on the port you set as internal_port in fly.toml.
If you hardcode 3000, the platform can’t reach your app. Read the port from the environment, with a fallback for local development:
import express from 'express'
const app = express()
app.get('/', (req, res) => {
res.send('Hello')
})
const port = process.env.PORT || 3000
const server = app.listen(port, '0.0.0.0', () => {
console.log(`Listening on port ${port}`)
})
I explain how process.env works in how to read environment variables from Node.js.
Listen on 0.0.0.0, not localhost
A server listening on localhost or 127.0.0.1 only accepts connections from the same machine. The platform’s proxy is outside your container, so every request fails. Render, Railway and Fly.io all ask you to bind to 0.0.0.0.
If you call listen(port) with no host, Node.js listens on :: (or 0.0.0.0 when IPv6 isn’t available), and on most systems that accepts outside connections too. The problem usually comes from a framework or a dev server that defaults to localhost. Passing '0.0.0.0' yourself, like in the example above, removes the guesswork.
Pin the Node.js version
If you don’t choose a version, the host picks one, and that default changes over time. Add engines to package.json:
{
"engines": {
"node": "24.x"
}
}
Use a major range like 24.x, not >=24. A range with no upper limit lets the host jump to a new major version you never tested.
Heroku and Render both read engines. Render also reads a .node-version or .nvmrc file in the repo root, and those win over engines if you have both.
Don’t store files on the local disk
On a PaaS the disk is temporary. On Heroku, anything your app writes is gone when the dyno stops or restarts, and if you run two dynos, each one has its own separate disk.
So put user uploads in object storage like S3 or Cloudflare R2, and data in a database. If you really need a disk, Render and Railway offer persistent volumes. On Render, adding a persistent disk turns off zero-downtime deploys.
With serverless it’s the same idea, applied to memory too. An instance can disappear between two requests, so don’t keep sessions, caches or setInterval jobs in memory.
Shut down cleanly on SIGTERM
When you deploy a new version, or the platform restarts your app, it sends your process a SIGTERM signal. If the process is still running after a grace period, it gets killed with SIGKILL. On Heroku that period is 30 seconds. On Render it’s 30 seconds by default, and you can raise it up to 300 with the maxShutdownDelaySeconds setting. systemd and docker stop send SIGTERM too.
Use that time to stop accepting new connections and let the requests in progress finish:
process.on('SIGTERM', () => {
server.close(() => {
process.exit(0)
})
// don't wait forever on slow connections
setTimeout(() => process.exit(1), 10_000).unref()
})
server is the value returned by app.listen() in the first example.
In Docker, start the app with CMD ["node", "server.js"] instead of CMD ["npm", "start"], so the signal reaches Node.js directly and doesn’t stop at npm. I go deeper on signals and exit codes in how to exit from a Node.js program.
Watch out for NODE_ENV=production at install time
Set NODE_ENV=production when your app runs. Express and many other libraries use it to turn off development features.
But if it’s already set when npm install runs, npm skips devDependencies. If your build step needs TypeScript, Vite or another dev dependency, the build fails with a “command not found” error. Either move those packages to dependencies, or install with npm install --include=dev before you build.
Want me to talk about your product? You can sponsor this site.
Related posts about node: