Menu

Run a Node.js App on AWS EC2 (and Why It Stops When You Close SSH)
📰

Run a Node.js App on AWS EC2 (and Why It Stops When You Close SSH)

DEV Community: aws·Jahid Hiron·9 days ago
#1hnhOM4l
#devtoaws#devto#dev#node#server
Long article (374 words) — no AI summary yet.
Reading 0:00
15s threshold

My Node app ran fine on my laptop. Getting it to run on a real server took 3 commands. Keeping it running took one more tool.

This post is part of my series on deploying a Node.js app to AWS. By now I have an Ubuntu EC2 instance, Node.js 22 and Git installed, and my project cloned from GitHub. If you're not there yet, the earlier steps are linked at the end.

1. Find the project folder

SSH into the server and list what's in your home folder:

ls

Enter fullscreen mode

Exit fullscreen mode

My project is called node-api . Move into it:

cd node-api

Enter fullscreen mode

Exit fullscreen mode

2. Install the dependencies

The node_modules folder is never in Git, so the server doesn't have it yet. Install it:

npm i

Enter fullscreen mode

Exit fullscreen mode

If this fails, check your Node version first with node -v . An old Node version is the most common cause. I'm on Node 22.

3. Start the app

npm start

Enter fullscreen mode

Exit fullscreen mode

My app prints that it's listening on port 4000.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.