AWS Builder Center
Deploy a Node.js Application on AWS EC2: A Step-by-Step Guide

Deploy a Node.js Application on AWS EC2: A Step-by-Step Guide

Learn how to launch an Amazon EC2 instance, configure a Linux environment, and deploy a Node.js application on AWS. This beginner-friendly guide covers instance setup, SSH connectivity, application deployment, and accessing your application over the internet.

Deploy a Node.js Application on AWS EC2 Introduction Deploy an application locally is different from making it accessible to users worldwide. AWS provides cloud services that help developers host and manage applications efficiently. In this article, we'll explore how to deploy a basic Node.js application using Amazon EC2(Elastic Compute Cloud).
What is Amazon EC2? Amazon EC2 is an AWS service that provides virtual servers in the cloud. Developers can launch instances, configure operating systems, and run applications without managing physical hardwae.
Step 1: Launch an EC2 Instance 1. Log in to the AWS Management 2. Open Amazon EC2 and select Launch Instance. 3. Choose Ubuntu Server as the operating system. 4. Select an appropriate instance type. 5. Create or select an SSH key pair. 6. Configure security group rules for SSH(port 22) and your application port(3000) Launch the instance and wait until it becomes active.
Step 2: Connect to the instance Use SSH to connect to your Ubuntu server: ssh -i my-key.pem ubuntu@YOUR_PUBLIC_IP
Step 3: Install Node.js Update your server and install Node.js: sudo apt update sudo apt install nodejs npm -y Verify the installation: node -v npm -v
Step 4: Deploy Your Application: Clone your project from GitHub: git clone YOUR_REPOSITORY_URL cd YOUR_PROJECT_NAME npm install npm start
Ensure your application listens on 0.0.0.0 and the confugured port.
Step 5: Access Your Application Open your browser and visit:  http://YOUR\_PUBLIC\_IP:3000 
If everything is configured correctly, your Node.js application should now be accessible through your EC2 instance.
Conclusion
Deploying a Node.js application on Amazon EC2 is a great way to understand cloud computing and server management.
By completing these steps, you've learned how to launch a virtual server, connect through SSH, install dependencies, and host an application on AWS.
Next Step: Explore Amazon S3, Docker, Nginx, and AWS CI/CD services to improve your deployment skills.
Happy Building!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article