1
votes

I am trying to connect to my postgres database which is install on AWS EC2 instance.

I have installed pgadmin3 on my local ubuntu machine and I am trying to connect my postgres but I am getting error:

 reports could not connect to server: Connection refused Is the server running on host "myip" and accepting TCP/IP connections on port 5432? 

On aws I have open port 5432.

I edited my postgresql.conf and I added :

 listen_addresses = '*'

and inside pg_hba.conf I added this:

host    all         all         192.168.1.0/24        md5

But now I am getting this error:

 FATAL: no pg_hba.conf entry for host "myip", user "postgres", database "postgres", SSL on FATAL: no pg_hba.conf entry for host "myip", user "postgres", database "postgres", SSL off getting this error
2

2 Answers

1
votes

You have to edit postgresql.conf file and change line with 'listen_addresses'.

listen_addresses = '*'

Then you have edit pg_hba.conf file, too. In this file you have set, from which computers you can connect to this server and what method of authentication you can use. Usually you will need similar line:

host    all         all         192.168.1.0/24        md5
1
votes

I solved this by adding this line to postgresql.conf :

listen_addresses = '*'

file location of postgresql.conf is:

/etc/postgresql/9.5/main/postgresql.conf

And I added this line in file pg_hba.conf:

 # IPv4 local connections:
 host    all             all             0.0.0.0/0               md5
 host    all             all             127.0.0.1/32            md5

And restarted postgres service using:

sudo service postgresql restart