I'm trying to connect to a postgresql database using the following python code:
try: conn = psycopg2.connect("host = '10.47.65.237' dbname = 'testDB' user = 'pi' password = 'raspberry'") except: print("Unable to connect to testDB at 10.47.65.237. Sending Alert.") This code works with localhost 127.0.0.1 but when I go to a different machine and try to run it with its ip above it won't connect.
Things I've done: 1. Port 5432 is open 2. edited postgresql.conf by adding the line "listen_addresses='10.47.65.138'" 3. edited pg_hba.conf by adding the following configuration "host all all 10.47.65.138 md5"
Any other things I could try or I'm missing?
telnet 10.47.65.237 5432, do you get a successful connection, or do you get a Connection Refused error, or does it just hang?