SajjadZare
SajjadZare

Reputation: 2378

Canot connect to postgresql server from out

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?

Upvotes: 1

Views: 1217

Answers (2)

OkieOth
OkieOth

Reputation: 3714

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.

Upvotes: 1

francs
francs

Reputation: 9219

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

Upvotes: 1

Related Questions