I have created an DB instance as follows:
with the security groups below. With the inbound rule set to my IP.
However when using :
import psycopg2
import logging
engine = psycopg2.connect(
database="postgres",
user="xxxxx",
password="xxxxx",
host="xxx.rds.amazonaws.com",
port='5432'
)
I get the traceback error:
Traceback (most recent call last):
File "/Users/samuelwilson/trading/aws_connection.py", line 3, in <module>
engine = psycopg2.connect(
File "/Users/samuelwilson/trade/lib/python3.8/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "xxx.us-east-1.rds.amazonaws.com" (3.223.2.177), port 5432 failed: Operation timed out
Is the server running on that host and accepting TCP/IP connections?
After then checking netstat for 5432, straight after running the script i get:
tcp4 0 0 192.168.0.15.54327 17.253.35.204.80 TIME_WAIT
tcp4 0 0 192.168.0.15.54329 17.253.35.203.80 TIME_WAIT
ee3b4653a1174d4b stream 0 0 ee3b46539fa87793 0 0 0 /tmp/.s.PGSQL.5432
But shortly after only: ee3b4653a1174d4b stream 0 0 ee3b46539fa87793 0 0 0 /tmp/.s.PGSQL.5432
Showing no tcp connection to 5432.
I have updated my postgresql.conf listen_addresses to '*' and pg_hba.conf i added the following:
host all all 0.0.0.0/0 trust
If IPv6:
host all all ::/0 trust
host all all 3.223.2.177 trust
If IPv4:
host all all ::/0 trust
If IPv4:
host all all 3.223.2.177 trust
'''