1

I want to connect to postgresql from another server but occur below error. i search and find some result like below but after do these again error occured

in postgresql.conf change listen_addresses from localhost to *

in pg_hba.conf change 127.0.0.1/32 to 0.0.0.0/0

reboot server

Error:

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

1
  • If connecting from localhost works, the cause of your problem probably lies within the firewall of the server Postgres is running on. Commented May 13, 2013 at 9:30

2 Answers 2

1

I suggest that you should do as the following steps.

  1. Check your PostgreSQL SERVER is running.
  2. Check the listen_addresses parameter ( postgresql.conf )
  3. Check the port number of your postgresql ( The port parameter of postgresql.conf )
  4. Check your the firewall policy of your database server , set that allow the port of your postgresql.
  5. If you want to connect your db from another server, may be you shoud set the pg_hba.conf as following :
 # TYPE DATABASE USER CIDR-ADDRESS METHOD local all all trust host all all 0.0.0.0/0 md5 
Sign up to request clarification or add additional context in comments.

3 Comments

I check all of your steps,but again can't access
@SajjadZare Then maybe a firewall/router between your DB server and the outside is filtering the traffic out. Use tcpdump or wireshark to trace. Also make sure you aren't using a private IP like 196.168.x.x, 172... or 10.x.x.x and that you don't have any NAT in place.
Is it possible to use tcpdump in ssh?
1

Try to check if the network traffic reaches the server. You can sniff the network traffic to see what happen. Meassure on client and server and check the communication.

sudo tcpdump -A -n -s 0 -w test_on_client.log port 5432 

After you try your connect stop tcpdump with CTRL-C and inspect the log file with Wireshark. This procedure will find every network connection problems.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.