Facebook Pixel

How to Launch an AWS EC2 Instance Step-by-Step Guide for Node.js Developers

Learn how to launch an AWS EC2 instance from scratch choosing an AMI, selecting an instance type, configuring security groups, creating key pairs, and connecting via SSH.

How to Launch an AWS EC2 Instance

This step-by-step guide walks through launching an EC2 instance for deploying a Node.js application.

Step 1: Sign In to AWS Console

  1. Go to https://console.aws.amazon.com
  2. Sign in with your AWS account
  3. Select a region (e.g., us-east-1 N. Virginia) choose one close to your users

Step 2: Launch an Instance

  1. Go to Services → EC2 → Instances
  2. Click Launch Instance
  3. Give it a name (e.g., "devtinder-backend")

Step 3: Choose an AMI

Select Ubuntu Server 22.04 LTS (or 24.04 LTS). It's the most common choice for Node.js because:

  • Large community and documentation
  • apt package manager is easy to use
  • Long-term support (LTS) ensures stability

Step 4: Choose an Instance Type

For development: t2.micro (free tier) For production: t3.small or t3.medium

Click Next: Configure Instance Details.

Step 5: Configure Instance

  • Number of instances: 1
  • Network: Default VPC
  • Subnet: Default (or choose one in your preferred AZ)
  • Auto-assign Public IP: Enable (so you can SSH in)

Step 6: Add Storage

Default is 8 GB. For a Node.js app, 20-30 GB is sufficient. Use gp3 (general purpose SSD) for better performance at lower cost.

Step 7: Add Tags

Add a tag:

  • Key: Name
  • Value: devtinder-backend

This helps you identify the instance in the console.

Step 8: Configure Security Group

Create a new security group named "devtinder-sg":

TypeProtocolPortSource
SSHTCP22My IP
HTTPTCP800.0.0.0/0
HTTPSTCP4430.0.0.0/0
Custom TCPTCP3000My IP

Important: For SSH, use "My IP" (AWS auto-detects your current IP). Never use 0.0.0.0/0 for SSH.

Step 9: Create a Key Pair

  1. Click Create a new key pair
  2. Name it "devtinder-key"
  3. Choose RSA and .pem (for Mac/Linux/Windows PowerShell)
  4. Click Create key pair

The .pem file downloads automatically. Save it securely you cannot download it again.

Step 10: Launch

Click Launch Instance. Wait 1-2 minutes for the instance to start.

Step 11: Connect via SSH

Find the public IP in the EC2 console. Then:

# Set permissions on the key file (Mac/Linux) chmod 400 devtinder-key.pem # Connect ssh -i devtinder-key.pem ubuntu@your-public-ip

For Windows, use PuTTY or Windows PowerShell (use the .pem file directly).

Step 12: Verify the Connection

You should see:

Welcome to Ubuntu 22.04 LTS
...
ubuntu@ip-172-31-xx-xx:~$

Step 13: Allocate an Elastic IP (Optional but Recommended)

By default, the public IP changes when you stop/start the instance. To get a static IP:

  1. Go to EC2 → Elastic IPs
  2. Click Allocate Elastic IP address
  3. Select the allocated IP
  4. Actions → Associate Elastic IP address
  5. Select your instance and associate

Now your instance has a permanent public IP.

The Takeaway

Launching an EC2 instance involves: choosing Ubuntu AMI, selecting instance type (t2.micro for dev), configuring security group (SSH from your IP, HTTP/HTTPS from anywhere), creating a key pair (.pem file), and connecting via SSH. For production, allocate an Elastic IP so the address doesn't change on restart.

Go to EC2 console, click Launch Instance, choose Ubuntu 22.04 LTS AMI, select t2.micro (free tier), configure security group (SSH from your IP, HTTP/HTTPS from anywhere), create a key pair, and launch. Connect via SSH using the .pem file.

Ubuntu Server 22.04 LTS or 24.04 LTS. Ubuntu has a large community, easy-to-use apt package manager, and long-term support for stability. It's the most common choice for Node.js deployment.

Use SSH with the key pair .pem file. On Mac/Linux: chmod 400 key.pem, then ssh -i key.pem ubuntu@public-ip. On Windows, use PuTTY or PowerShell. Find the public IP in the EC2 console.

Yes, for production. By default, the public IP changes when you stop/start the instance. An Elastic IP is a static public IP that persists across restarts. Go to EC2 → Elastic IPs → Allocate, then associate with your instance.

SSH (port 22) from your IP only, HTTP (port 80) from 0.0.0.0/0, HTTPS (port 443) from 0.0.0.0/0. Optionally port 3000 from your IP for direct Node.js debugging. Never open port 3000 to the public use Nginx as a reverse proxy.

Ready to master Node.js completely?

Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.

Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.