I have installed Postgres 10 on my EC2 ubuntu(18). But I can't access it from my Local Mac. Get this error.
My SETUP is:
I updated Postgres configs:
- to /etc/postgresql/10/main/pg_hba.conf added these lines:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
- in /etc/postgresql/10/main/postgresql.conf changed this line:
listen_addresses = '*' # what IP address(es) to listen on;
- I did set password to default 'postgres' user, which I am using to connect to DB from outside;
On EC2 instance I changed:
On EC2 instance this command returns that port is exposed:
ubuntu@ip-XXXXXXXXXX:~$ netstat -nat |grep :5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
Looks like EC2 instance did not expose this port in fact. Other ports like :80 or :22 are accessible fine, but port :5432 returns error:
➜ ~ nc -zv XX.XXX.XXX.XXX 80
Connection to XX.XXX.XXX.XXX port 80 [tcp/http] succeeded!
➜ ~ nc -zv XX.XXX.XXX.XXX 5432
nc: connectx to XX.XXX.XXX.XXX port 5432 (tcp) failed: Operation timed out
I also have Nginx installed on my EC2 instance, its config is:
server {
charset utf-8;
listen 80;
server_name XXXXXXXXXXXXXXX.ca; # <--- hidden domain name
location / {
root /opt/frontend/develop/dist/tweeter-ui/;
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://localhost:8080/api/;
}
}
PostgreSQL service is running:
ubuntu@ip-XXXXXXXXXX:~$ service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2022-11-23 22:41:33 UTC; 1h 6min ago
Process: 6283 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 6283 (code=exited, status=0/SUCCESS)
Nov 23 22:41:33 ip-XXXXXXXXXX systemd[1]: Starting PostgreSQL RDBMS...
Nov 23 22:41:33 ip-XXXXXXXXXX systemd[1]: Started PostgreSQL RDBMS.
What is wrong in my setup? I tried many different posts in this forum and on Internet, nothing helps. (( Do I have to also configure Nginx with Postgres routing?