I have personal AWS EC2 server and I'm using ssh into this server. I installed PostgreSQL on the EC2 instance, cerated a PostgreSQL RDS, and trying to connect to the RDS from EC2 CLI. I get following error:
Is the server running on host "db-xxxx.us-east-2.rds.amazonaws.com" and accepting TCP/IP connections on port 5432?
I have: - change RDS to publicly accessible - added listen_addresses = '*' to postgres.conf - added 0.0.0.0/0 md5 to pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/0 md5
- ensured both EC2 and RDS have same security group
- added security-group-for-inbound-nfs-xx to RDS
enabled IAM authorization on RDS
output of "service postgresql status" shows postgres is running and listening on the port 5432
Redirecting to /bin/systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-06-03 04:28:54 UTC; 20min ago
Process: 3065 ExecStartPre=/usr/libexec/postgresql-check-db-dir %N (code=exited, status=0/SUCCESS)
Main PID: 3070 (postmaster)
CGroup: /system.slice/postgresql.service
├─3070 /usr/bin/postmaster -D /var/lib/pgsql/data
├─3084 postgres: logger process
├─3089 postgres: checkpointer process
├─3090 postgres: writer process
├─3091 postgres: wal writer process
├─3092 postgres: autovacuum launcher process
├─3093 postgres: stats collector process
└─3094 postgres: bgworker: logical replication launcher
I see postgres is running and listning on the port 5432.
postmaster[3070]: 2020-06-03 04:28:54.168 UTC [3070] LOG: listening on IPv4 address "0.0.0.0", port 5432 Jun 03 04:28:54 ip-172-xx-xx-xx9.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.168 UTC [3070] LOG: listening on IPv6 address "::", port 5432 Jun 03 04:28:54 ip-172-xx-xx-xx9.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.169 UTC [3070] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" Jun 03 04:28:54 ip-172-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.171 UTC [3070] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" Jun 03 04:28:54 ip-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.198 UTC [3070] LOG: redirecting log output to logging collector process Jun 03 04:28:54 ip-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.198 UTC [3070] HINT: Future log output will appear in directory "log". Jun 03 04:28:54 ip-172-31-36-109.us-east-2.compute.internal systemd[1]: Started PostgreSQL database server.
I have verified everything provided here:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
https://aws.amazon.com/premiumsupport/knowledge-center/rds-connectivity-instance-subnet-vpc/
What am I missing? Thanks for the help.
IAM authorization on RDS
, does the instance has role with permissions to connect to the RDS? – Marcin