This guide shows how to host a small Express.js website on an Amazon EC2 Ubuntu instance: upload the app, install dependencies, and keep it running with PM2 so it survives SSH disconnects.
What is Express.js on EC2?
Express is a minimal Node.js web framework. On EC2 you get a Linux VM where you install Node, copy project files, and listen on a port the security group allows. That pattern suits APIs, SSR apps, and small sites.
When should you use this approach?
Use a single EC2 + Express setup for learning, demos, and small workloads. For production scale, put an Application Load Balancer (and often CloudFront) in front, add HTTPS, and avoid running Node as root on port 80.
What you will build
A two-file sample (index.js + hello-world.html), uploaded with FileZilla, started with PM2, and opened in a browser via the instance public DNS or Elastic IP.
Tools in this walkthrough
PuTTY (or SSH) for commands, Node.js and npm on Ubuntu, FileZilla for SFTP, and PM2 as the process manager.
Local Express install.
Always run npm install express inside the project folder so require('express') resolves from node_modules.
Avoid chmod 777 in production.
Wide-open permissions are only for a quick demo upload. Prefer chown for your deploy user and tight modes on app folders and keys.
Port 80 is privileged.
Listening on 80 usually needs elevated privileges. Production setups often run Node on a high port behind Nginx or an ALB on 80/443.
Reference
Core Concepts
Terms you will use while deploying:
Concept
Meaning
EC2 instance
Virtual server (here: Ubuntu) that runs your Node process
Express
Node framework for routes, static files, and HTTP responses
PM2
Process manager that keeps the app up after SSH logout
Security group
Firewall allowing inbound TCP (e.g. 22 for SSH, 80 for HTTP)
Elastic IP
Stable public IPv4 so the address survives stop/start
SFTP / FileZilla
Secure file transfer of project files to the instance
express.static
Middleware that serves files from a folder such as public/
Install locally:npm install express in the project—not a global Express for require.
PM2: keeps the process running after SSH disconnect; open the right security group ports.
Demo vs prod: port 80 + sudo is fine for learning; production wants proxy/ALB + HTTPS.
Permissions: skip lasting 777; use least privilege after uploads.
One line: upload the app, npm install express, pm2 start, open port 80, then harden for production.
Frequently Asked Questions
PM2 is a Node.js process manager. It keeps your app running after you disconnect SSH, can restart it on crash, and provides basic status and logging commands.
No. Install Express in the project folder with npm install express so require('express') resolves from node_modules. Global installs are not required for a normal Express app.
On Linux, ports below 1024 are privileged. Run PM2 with elevated privileges for demos, or listen on a high port and put Nginx (or an ALB) on 80/443 in front.
It is strongly recommended. Without an Elastic IP, the public IPv4 address can change when you stop and start the instance, which breaks bookmarks and DNS until you update them.
No. Use it only for a quick FileZilla demo if needed, then tighten ownership and permissions. Prefer chown for your deploy user and least-privilege modes.
Add HTTPS (ACM + ALB or a reverse proxy), pm2 startup on reboot, log rotation, monitoring, and avoid exposing Node directly on port 80 in production.