Reputation: 3588
I think I followed any possible guide before asking here.
I am trying to remotely connect to a PostgreSQL db installed on a EC2 Linux instance (Ubuntu server 18.04, free tier if it matters).
Here are all the steps I did before hitting a wall and begging for help.
I edited /etc/postgresql/10/main/pg_hba.conf
adding these lines:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
I edited /etc/postgresql/10/main/postgresql.conf
changing #listen_addresses = 'localhost'
into listen_addresses = '*'
i restarted the postgres server with sudo service postgresql restart
I added a new Inbound rule in the instance security group like so:
TCP port:5432 source:0.0.0.0/0, ::/0
After all, I am trying to connect from my local mahine (either using pgadmin3 or psql) but I still receive a timeout error (host is hidden):
psql -h <PUBLIC-IP-OF-MY-INSTANCE> -U umberto -d wondermap
or even
psql -h <PUBLIC-IP-OF-MY-INSTANCE> -U postgres
psql: could not connect to server: Connection timed out
Is the server running on host "<PUBLIC-IP-OF-MY-INSTANCE>" and accepting
Doing SELECT version();
shows:
PostgreSQL 10.7 (Ubuntu 10.7-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0, 64-bit
What could be the problem?
Upvotes: 1
Views: 1570
Reputation: 3588
Apparently, I stil had to unblock postgres port on server's firewall.
sudo ufw allow 5432/tcp
That did the trick!
Upvotes: 4