I am trying to configure postgresql 9.1 server on ubuntu for remote data access. I installed postgres correctly, the server process is running, and I'm trying to configure it so that I can remotely access the server via the Internet from several other computers outside the local network.
I already changed my pg_hba.conf with
host all all 0.0.0.0 trust
and postgresql.conf with:
listen_addresses = '*' port = 5432
I also modified my iptables to accept connections on port 5432.
When I try to connect using psycopg2 in python:
conn=psycopg2.connect('host=XX.XX.XX.XX port=5432 dbname=postgres user=myUser password=mypassword')
I get the following error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect connection_factory=connection_factory, async=async) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "XX.XX.XX.XX" and accepting TCP/IP connections on port 5432?
I'm not sure if I inserted the correct IP address, and I am curious to know how exactly I will use the IP address to connect to my server. I used the public IP address of my computer running the postgres server, but I'm not sure if this is correct. Or is there another step I'm still missing? I know this is a bad security style, but for now I would just like to establish a connection. My computer is also behind the router, so how can I access my server?
Any help is greatly appreciated.