I'm connecting to a Postgresql database running in an Ubuntu server. I had no problem doing this from the office but when I tried connecting from home, the connection was refused.
FATAL: no pg_hba.conf entry for host "XX.XXX.XX.XX", user "postgres", database "postgres", SSL off
So, I added my ip to the conf file
host all postgres XX.XXX.XX.XX md5
Thinking I was done, a new error appeared:
could not connect to server: Connection refused
Is the server running on host "YYY.YY.YY.YY" and accepting
TCP/IP connections on port 5432?
I added my ip to the server firewall and still the connection is refused and the same error keeps showing up, even if the server is running and accepting connections on port 5432 From ufw:
5432/tcp ALLOW IN XX.XXX.XX.XX
So, is it weird that at first the connection was refused by the database in the server, and then it was refused by the server itself and not the other way around? Also, if the server is running and accepting connections in that port, what else can I try to fix my problem?
I solved the prbolem. In the conf file, instead of the line
host all postgres XX.XXX.XX.XX md5
I added
host all all XX.XXX.XX.XX/32 md5
And now it works fine.