1. Knowledge Base
  2. Admin
  3. Database Administration

What IP address should I put in my pg_hba.conf file?

That's called CIDR notation. Here's a handly calculator for figuring out an appropriate value: http://www.subnet-calculator.com/cidr.php.

You need to know a little about the network you're setting the server up on and a bit about subnetting. A client may need to allow various networks to connect - they may have several subnets, etc - each network from where you want to allow connections from needs to have an entry in the pg_hba.conf, or at least a rule that fits. is a catch-all - any address will match with that rule.

But, suppose you have a remote office, with a fixed IP on their router - all traffic from inside the office goes out with the same WAN IP of that router, say the WAN IP is - that's a single address from a single device. So, on your postgres server where they are connecting to you would create a pg_hba.conf entry similar to:

host all all md5 /32
is the same as ( 1 address) /24
is the same as (254 addresses)

Also, keep in mind that the pg_hba.conf file is read top to bottom. As soon as Postgres finds a rule that allows access, it stops reading rules - so make sure your access rules make sense. You can do all sorts of interesting things with the pg_hba.conf. Read the comments at the top of that file.