0

I'm completed the installation of PG server. I want to be able to be able to remote connect to it with pgAdmin but keeps on getting server don't listen error.

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

It's on my network and I know I have to edit pg_hba.config file. Everywhere I read, I have to add a line,

host    all         all         ip address/mask    md5

My question is, what is the /mask and how/where do I get it? The IP I'm connecting from is 192.168.1.9.

Thank you so much for your time, I am using Ubuntu 16.04 and Postgresql 9.4.

6
  • host all all 192.168.1.9/32 md5 and put it not to the end, but to the begining of "host" section - just after "local" Commented Jun 14, 2016 at 7:40
  • You are likely to have /24 or /16 subnet. If you chose /32 it means only this address can connect. Commented Jun 14, 2016 at 7:41
  • according to your error message , look at your postgresql.conf listen_addresses = '*' Commented Jun 14, 2016 at 7:52
  • @RémyBaron i have listen_addresses=* on my file. Commented Jun 14, 2016 at 8:17
  • @VaoTsun , what is /32? is there a logically way to determine it? Commented Jun 14, 2016 at 8:18

1 Answer 1

3

The number after the / is actually not a mask, but the CIDR mask length.

It states how many leading bits must match the IP address preceeding the / for an incoming address to match the pg_hba.conf entry.

If you want the line to only work for your host, use 192.168.1.9/32 (all 32 bits must match).
To have the line apply to all hosts that start with 192.168.1., use 192.168.1.0/24.
To match all hosts, use 0.0.0.0/0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.