Last updated: January 20th, 2024

If you’re a Node.js developer, no matter whether your stack is plain templating (I’m looking at you EJS folks!), MEAN, MERN, MEVN or really anything, this article is meant to be a comprehensive, beginner-friendly guide at hosting your web application on an AWS EC2 instance.

Prerequisites

  1. A public repository on Github/Gitlab so that the project can easily be brought to the server.

Otherwise, you will have to bring it manually via something like FTP, which is beyond the scope of this article.

  1. Register an account on Amazon AWS Console.

You may have to wait up to 24h for your account to be active and setup.

  1. Register an account on a domain registrar like GoDaddy or Namecheap.

You will also have to buy a domain name of your choice.


Now that’s out of the way, let’s get started hosting our MERN/MEAN/MEVN-stack application on an Amazon AWS EC2 and that too for free! (If you’re on a new account, for up to an year).

AWS offers a generous free tier where they provide 750 hours/month for an EC2 instance which is more than enough to run a full-stack node project for a year.

⚠️ Note: Only have one instance running at any given time. If at any point you feel the need to restart the process, be sure to terminate the existing instance completely. Do not leave it running as this will incur you costs.

Setting up an AWS EC2 instance.

Creating the instance.

  1. Select “Launch Instance” from the AWS EC2 Console

Untitled

  1. Enter a suitable name for your server.

Untitled

  1. Select Ubuntu as your Amazon Machine Image (AMI). I am using Ubuntu Server 22.04 LTS4.