---
title: "Discussion on \"Step-by-Step Guide to Deploy a Node.js Server on Amazon EC2 with NGINX and pm2\" | Hashnode"
description: "Discussion on \"Step-by-Step Guide to Deploy a Node.js Server on Amazon EC2 with NGINX and pm2\". Hello there! 🌟\nIn this guide, we'll walk through the step-by-step process of deploying a Node.js application on an AWS EC2 Ubuntu and accessing it in your browser. Whether you're a beginner or looking to brush up on your skills, this tutorial will m..."
url: "https://hashnode.com/posts/step-by-step-guide-to-deploy-a-nodejs-server-on-amazon-ec2-with-nginx-and-pm2/67d00c9b7b95633e4021cd19"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Step-by-Step Guide to Deploy a Node.js Server on Amazon EC2 with NGINX and pm2](https://abdevops.hashnode.dev/step-by-step-guide-to-deploy-a-nodejs-server-on-amazon-ec2-with-nginx-and-pm2?utm_source=hashnode&utm_medium=feed)

Hello there! 🌟 In this guide, we'll walk through the step-by-step process of deploying a Node.js application on an AWS EC2 Ubuntu and accessing it in your browser. Whether you're a beginner or looking to brush up on your skills, this tutorial will m...

Mar 11, 2025 · 6 min read · abdevops.hashnode.dev  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#devops](https://hashnode.com/tag/devops)

## Written by

[Abhijit Sagare](https://hashnode.com/@abhidevops)

@abhidevops · Bangalore india

  
[View profile](https://hashnode.com/@abhidevops)

Devops Engineer

## Responses 1

Markdown supported · ⌘↵ to post

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

[Nov 5](https://hashnode.com/posts/step-by-step-guide-to-deploy-a-nodejs-server-on-amazon-ec2-with-nginx-and-pm2/67d00c9b7b95633e4021cd19/comment/6aebd5a6e0adfb05219de1cb)

On a single EC2 host the durable layout is nginx terminating TLS on 443 and proxying to one PM2 listen bound on loopback. Let PM2 own cluster fan-out on that port — putting every worker port into an nginx upstream doubles fail surfaces and breaks affinity when a worker 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; leave the PM2 port off the security group.
