Hosting a server on AWS gives you full control over your computing environment. Whether you want to run a web server, game server, or backend service, Amazon EC2 allows you to do so with scalable virtual machines.
This guide shows you how to launch and access a basic server on AWS.
How to host a server on AWS

Step 1: Sign in to the AWS Console
Enter your login details to access the AWS Management Console.
Step 2: Launch an EC2 instance
In the search bar, type EC2 and open the EC2 Dashboard, and launch the instance. Under Name, enter a name for your server (e.g., my-server) and choose an Amazon Machine Image (AMI).
Now, choose an instance type and create a new key pair or use an existing one under Key pair. If it’s a new pair, you’ll also need to download the .pem file.
Now, go to Network settings and allow SSH (port 22 for Linux) or RDP (port 3389 for Windows) and then click on Launch Instance.
Step 3: Connect to your server
Now, you need to connect to your server. The process will differ depending on the OS you’re using. Follow the respective steps below.
For Linux/Mac
Open your terminal, navigate to the folder where the .pem
file is saved and change its permission using the following command:chmod 400 my-key.pem
Now, connect using SSH:ssh -i "my-key.pem" ec2-user@your-public-ip
You’ll get an output that looks something like this:
Welcome to Amazon Linux 2023
[ec2-user@ip-172-31-xx-xx ~]$
For Windows
Open Windows Terminal (or Command Prompt or PowerShell) and navigate to the folder where your .pem file is located.
Now, run this command to set file permissions:
icacls my-key.pem /inheritance:r
icacls my-key.pem /grant:r "%username%:R"
Next, use the SSH command to connect to your instance.
ssh -i "my-key.pem" ec2-user@your-public-ip
Step 4: Set up the server environment
Once you’re connected, you can install and start a web server. Once installed and running, your EC2 instance will serve as a default test page when accessed in a browser.
Step 5: View the server in your browser
Now, go to EC2 Dashboard > Instances, copy the Public IPv4 address of your instance and paste it in your browser to view and check it.
FAQ
What do I need to host a server on AWS?
To host a server on AWS, you need an AWS account, an EC2 instance, and a key pair to connect securely. You’ll also need to open necessary ports in the security group.
Is hosting a server on AWS free?
The AWS Free Tier offers 750 hours/month of t2.micro or t3.micro instances for the first 12 months. Beyond that, you’ll need to pay as per the charges based on usage.
How do I keep my server running 24/7?
To keep your server running 24/7, you just need to keep the instance running. Make sure your usage stays within free limits or set up billing alerts to monitor costs.
How can I stop the server when not in use?
To stop the server when not in use, go to EC2 > Instances, select your server, and click Instance state > Stop instance. This will stop the server and you can start the server anytime again.