3

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 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

5 Comments

I am using ubuntu where is the location of that file
Look in this location : /etc/postgresql/9.3/main. Replace 9.3 with the version you installed
this file pg_hba.conf is empty
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
Have a look at this SO post: stackoverflow.com/q/14545298/1225070

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.