Self-Hosting a VPN on AWS Using OpenVPN
Setting up your own VPN is a great way to secure internet connections, protect privacy, and gain control over your data. In this guide, I’ll show you how I set up a self-hosted VPN on AWS using the OpenVPN Access Server. This VPN solution offers a simple and reliable way to establish secure connections for personal use, with AWS’s EC2 providing a powerful, scalable infrastructure.
Prerequisites
AWS Free Tier account (optional but beneficial for beginners)
Basic familiarity with SSH and EC2 instances
Step 1: Launch an EC2 Instance with OpenVPN
Launch a new instance and search for the OpenVPN Access Server AMI in the AWS Marketplace.
Select an instance type:
t3.micro: Free under the AWS Free Tier, suitable for running OpenVPN Access Server.
t2.nano: An economical choice if not using the Free Tier, costing around $0.006 per hour, capable of supporting OpenVPN’s needs for up to two devices.
Configure network settings to allow essential traffic only. Open port 1194 (UDP) for the VPN connection and port 943 for the admin interface.
Launch the instance with an SSH key pair for secure access.
VPN Location Matters: The location of your VPN server is based on the AWS region where the EC2 instance is hosted. For example, if your instance is in us-east-1 (North Virginia), your internet traffic will appear to originate from the United States. Similarly, hosting in ap-south-1 (Mumbai) routes traffic through the Indian internet. Choose a region based on the geographic benefits or restrictions you prefer.
Step 2: SSH into the Instance and Set Up the Admin User
Once your instance is running, SSH into it by the SSH code provided by the AWS.
Accept the licenses and agreements & keep the default settings.
You’ll be prompted again to login but as
openvpnas
.Configure the admin password for the OpenVPN Access Server by running:
sudo passwd openvpn
Enter a strong password for logging into the OpenVPN admin portal. The same credentials can be used to access the user portal.
Step 3: Access the OpenVPN Admin Portal
Open a browser and navigate to the admin portal at:
https://your-ec2-instance-public-ip:943/admin
Log in with the credentials you set in the previous step.
Configure your VPN settings as needed. This includes adding users, enabling multi-factor authentication (Optional).
Make sure both the options in the routing section are marked
YES
: Configuration/VPN Settings. Save the settings and update the running server.Note: OpenVPN Access Server's free license allows up to 2 simultaneous connections—suitable for personal use across two devices.
Step 4: Download and Install the OpenVPN Client
Now that your OpenVPN server is set up, open this URL:
https://your-ec2-instance-public-ip:943
This page provides a download link for the OpenVPN client, pre-configured to connect to your server.
Download and install the client on your device, then enter your VPN credentials when prompted. You’ll now be securely connected to your OpenVPN server on AWS!
Conclusion
In a few steps, you now have a fully operational, self-hosted VPN on AWS, enabling you to browse securely and privately from anywhere. This setup is highly effective for users who want more control over their internet security without recurring subscription costs. Despite being self-hosted, it’s not a slow VPN—AWS infrastructure ensures reliable and responsive speeds, making it suitable for streaming, browsing, and secure data access.
Benefits according to me:
Privacy and Control: Self-hosted means your data stays with you, without third-party access.
Geographic Flexibility: Choose your VPN location based on AWS regions, such as us-east-1 for the U.S. or ap-south-1 for India.
Cost Efficiency: AWS’s Free Tier and affordable instance types like t2.nano offer flexibility to meet your VPN needs on a budget.
I have been using this setup for a week now, and it’s been incredibly reliable on both my laptop and mobile. It doesn’t feel like I’m on a VPN 4K video playback is smooth, with almost no difference in speed before and after connecting. EC2 CPU usage is consistently below 10%, except during gaming, video calls, or on Discord.
Subscribe to my newsletter
Read articles from Aditya Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Aditya Raj
Aditya Raj
I'm passionate about software engineering and always eager to learn new technologies and collaborate.