Loading...
Loading...
This guide will walk you through setting up PostgreSQL on AWS EC2 with Ubuntu 22.04 LTS, including configuration for external connections and security best practices.
SSH into your EC2 instance:
Check PostgreSQL service:
Find the config file:
Look for:
Change it to:
Add at the end:
Note: This allows all IPs. For production, restrict to your specific IP range for security.
Restart PostgreSQL:
Login to PostgreSQL:
Inside psql:
Go to AWS Console → EC2 → Security Groups.
Edit inbound rules:
From your local machine:
It will ask for the password → connect.
✅ Now PostgreSQL is running and accessible publicly.
Don't keep it open to the whole internet (0.0.0.0/0). Better: