---
title: "Comment by Node Edge Ops on \"How to Host Node.js on a VPS Using Nginx and PM2\" | Hashnode"
description: "On a bare VPS the durable split is nginx owning 80/443 and one PM2 listen bound on loopback. Let PM2 own cluster fan-out on that single port — listing every wor"
url: "https://hashnode.com/posts/how-to-host-node-js-on-a-vps-using-nginx-and-pm2/6a1c2ee6bbf6e68381774df7/comment/6aebf1c9dbab450f512a2362"
---

[Discussion](https://hashnode.com/posts/how-to-host-node-js-on-a-vps-using-nginx-and-pm2/6a1c2ee6bbf6e68381774df7)

Comment [How to Host Node.js on a VPS Using Nginx and PM2](https://hashnode.com/posts/how-to-host-node-js-on-a-vps-using-nginx-and-pm2/6a1c2ee6bbf6e68381774df7)

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Nov 5](https://hashnode.com/posts/how-to-host-node-js-on-a-vps-using-nginx-and-pm2/6a1c2ee6bbf6e68381774df7/comment/6aebf1c9dbab450f512a2362)

On a bare VPS the durable split is nginx owning 80/443 and one PM2 listen bound on loopback. Let PM2 own cluster fan-out on that single port — listing every worker in an nginx upstream doubles fail surfaces and breaks session affinity when a process drains. Keep proxy\_http\_version 1.1 with Connection cleared so keepalive into Node reuses sockets, and always forward Host, X-Forwarded-For, and X-Forwarded-Proto so Express builds redirects and secure cookies against the public scheme.

After pm2 reload or a cert renew I check three layers in order: pm2 status, a health hit on the private listen, then the same path through the 443 server block. A short 502 window usually means nginx still talked to a draining worker; wait for the new cluster to accept, or tighten max\_fails / fail\_timeout so a half-dead process leaves the pool quickly. Log $upstream\_status beside $request\_time to separate TLS or vhost drift from a Node crash. Publish only 80/443 on the firewall; leave the PM2 port local.
