logo
Parslinks
Back to blog
Deploy5 min read

Node.js hosting: shared hosting, a VPS or a platform?

A Node.js app isn't a PHP site. It's an always-on process, not a set of files run on each request.

Alireza Tadi

Co-founder, Parslinks · Team, marketing & infrastructure

A freelance developer built an online ordering system in Node.js and Express for a group of restaurants in Isfahan. The client already had a cPanel host for their marketing site, and the panel even had a "Setup Node.js App" option. The app went up and worked. Three days later, at 8pm, the owner called: orders weren't coming through. Shared hosting kills processes that sit idle or exceed a memory cap, and the WebSocket connection that pushed orders live to the kitchen wasn't supported at all.

What does Node.js need from a host?

A PHP site is a set of files the web server runs on each request. A Node.js app is an always-on process that listens for requests itself. That difference creates a few concrete needs:

  • The process must stay up, and restart if it crashes.
  • The Node version must match the one you developed with.
  • If you use WebSockets or Server-Sent Events, the proxy in front must hold long connections open.
  • npm install and the build must run somewhere with access to the npm registry.

Three options side by side

Shared hosting, a VPS and a platform compared for a Node.js app

Shared hosting

Not the right place for Node.js, even if the panel offers it. It usually uses Passenger or something similar that stops the process when idle, has low memory limits and doesn't support WebSockets. Fine for an experimental API, not for something a client depends on.

A VPS

Anything is possible, as long as you build it. The common setup:

terminal
# Run the app with PM2 and bring it back after server reboots
npm ci --omit=dev
pm2 start dist/server.js --name orders -i 2
pm2 save
pm2 startup systemd
bash5 lines
/etc/nginx/sites-available/orders
location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_http_version 1.1;
    # Needed for WebSockets
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_read_timeout 3600s;
}
nginx9 lines

Add certbot for SSL, a script for git pull, build and restart, and a plan for OS patches. All doable; the responsibility is yours, and usually stays with whoever set it up on day one.

A platform

You connect the repo; the platform reads the Node version from package.json or .nvmrc, installs and builds, keeps the process up, and supports WebSockets behind its proxy. Every push gets a preview, and rolling back needs no rebuild.

package.json
{
  "engines": { "node": "22.x" },
  "scripts": {
    "build": "tsc -p .",
    "start": "node dist/server.js"
  }
}
json7 lines

Two things you need wherever you deploy

Listen on PORT, not a hard-coded number. Platforms pass the port as an environment variable: app.listen(process.env.PORT ?? 3000).

Graceful shutdown. When a new version ships, the old process gets SIGTERM. Stop accepting new connections and let in-flight requests finish. For the restaurant ordering app, that means an order being saved mid-deploy isn't lost.

In short

For Node.js, use shared hosting only for experiments. A VPS makes sense when someone on the team owns its upkeep. For most small and medium projects, a platform gives Node.js what it needs, without scripts only one person understands.

Frequently asked questions

Join the discussion

No comments yet. Be the first to share your thoughts.