Monday, 23 May 2016

postgis - Modifying "pg_hba.conf" file to listen local TCP/IP conection?


I am starting with PostGIS and there is an error when trying to connect through a TCP/IP connection. What I have done is: installed PostGre 9.3 in my PC, then installed PostGIS 2.3 for postGre 9.3, then I tested the database in my computer using localhost and all worked fine, then I wanted to connect to the database form another computer that is in the same network (from now on, PC2).. I read many forums and then modify pg_hba.conf trying to allow PC2 to connect. I just couldn´t.


Default file:



# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5


And this is how I modified it:


# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 10.0.0.99 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the

# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5

note that the new value is 10.0.0.99, which is the IP address of PC2.


Can anyone help?



Answer



Was dealling with same problem just few hours ago.


I think you should add a CIDR mask length (/32 for a single address - Wikipedia details) in ip-address section:


# TYPE  DATABASE        USER            ADDRESS                 METHOD


# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 10.0.0.99/32 md5
.
.
.

After saving pg_hba.conf file you should restart server with new configuration just run pgAdmin and choose Reload configuration in Tools menu: enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...