AWS EC2 gives you more control than Vercel, but it also gives you more responsibility.
On EC2, you manage the server. That means operating system updates, firewall rules, Node installation, process management, logs, Nginx, SSL, and cost awareness.
Quick answer
Use EC2 when you want to learn real server deployment or need a long-running Node.js process.
| Need | EC2 fit |
|---|---|
| Learn Linux server basics | Good |
| Long-running Node server | Good |
| Background worker | Good |
| Simple static site | Too much work |
| Beginner API with no server knowledge | Harder than Vercel |
| Full control | Good |
EC2 is powerful, but it is not automatically free forever. Always check AWS Free Tier and billing alerts.
basic deployment flow
The usual path:
- Create an AWS account.
- Launch an EC2 instance.
- SSH into the server.
- Install Node.js, npm, Git, and PM2.
- Clone your app.
- Install dependencies.
- Add environment variables.
- Run with PM2.
- Put Nginx in front.
- Add a domain and SSL.
That sounds like a lot because it is. But learning it once teaches you how servers work.
launch the instance
Choose:
- Ubuntu LTS.
- A small instance eligible for your account’s free tier or credits.
- A key pair you can safely store.
- Security group allowing SSH and web traffic.
Open only what you need:
| Port | Use |
|---|---|
| 22 | SSH |
| 80 | HTTP |
| 443 | HTTPS |
Do not open your database to the world.
install basics
SSH into the server, then:
sudo apt update
sudo apt install -y git curl
Install Node using a reliable method such as NodeSource, nvm, or your preferred version manager.
Then check:
node -v
npm -v
run the app with PM2
Clone your app:
git clone https://github.com/your-name/your-app.git
cd your-app
npm install
Start it:
npm run build
pm2 start npm --name "my-api" -- start
pm2 save
PM2 keeps the process running after crashes and restarts.
use Nginx as reverse proxy
Your Node app may run on port 3000. Nginx can receive traffic on port 80 and forward it to Node.
Example idea:
user -> domain.com -> Nginx :80/:443 -> Node app :3000
This is cleaner than exposing your Node port directly.
environment variables
Do not commit .env.
On the server, create environment values carefully:
nano .env
Or use PM2 ecosystem files if you know what you are doing.
Keep secrets out of GitHub.
free tier warnings
AWS Free Tier and free account plans can change. Check your account’s current benefits before launching resources.
Set:
- Billing alerts.
- Budget limits.
- No unused Elastic IPs.
- No forgotten instances.
- No unnecessary storage volumes.
The most expensive beginner mistake is forgetting a resource is still running.
EC2 vs Vercel
| Need | Choose |
|---|---|
| Fast static/blog deploy | Vercel |
| Next.js frontend | Vercel |
| Simple serverless API | Vercel |
| Learn Linux deployment | EC2 |
| Long-running server | EC2 |
| Background workers | EC2 or worker platform |
Vercel is easier. EC2 teaches more.
final advice
Use EC2 as a learning project if you want to understand real deployment. Use Vercel if your goal is simply to ship a web app quickly.
Either way, write down every step. Deployment notes become strong portfolio proof.
Discussion
What would you try, change, or challenge after reading this guide? Specific results and errors help the next reader.
Comments will load as you reach this section.