The file should be edited to allow external connections to the data base server pg_hba.conf
and restart the PostgreSQL Database Server service.
The file pg_hba.conf
is located in C:\Program Files (x86)\PostgreSQL\<version number>\data
. You can edit it in any text editor or with the pgAdmin utility.
To configure external connections using the pgAdmin utility:
- Run the pgAdmin utility.
- In the File menu, select Open pg_hba.conf....
- Select
pg_hba.conf
to configure the external connections. - In the window that opens, double-click in the empty checkbox for adding a new authorized connection.
- Specify the connection parameters:
- Enabled - Set the checkbox. If the checkbox is cleared, the connection will be preserved in
pg_hba.conf
as a comment, i.e. it will be inactive. - Type - Select "Host" from the dropdown list (authorization at the host level).
- Database - Select "All" from the dropdown list (the connection is authorized to all databases).
- User - Select "All" from the dropdown list (the connection is authorized for all users).
- IP Address - Specify the range of IP addresses (given as [IP address/Mask]) from which the connection will be made. For example: "192.168.1.112/32".
- Method - Select "md5" (the type of encryption for data transmission).
Tip
All addresses correspond to a "zero" subnet mask (signified by /0). A specific IPv4 address corresponds to a subnet mask with a 32-bit prefix (signified by /32).
- Enabled - Set the checkbox. If the checkbox is cleared, the connection will be preserved in
- If needed, add other connections in a similar manner (see step 5).
- Press CTRL+S to save
pg_hba.conf
, and close the pgAdmin utility.
To configure external connections using a text editor:
- Open
pg_hba.conf
using a text editor (for example, Notepad). - Find the following line in the file:
# Ipv4 local connections
- In the list that follows, at a record that corresponds to the range of IP addresses of the computers from which the connection
will be made.
For example:
host all all 192.168.0.7/32 md5
where:
- "host" means authorization at the host level.
- "all all" means access is available for all users to all databases.
- "192.168.0.7/32" is the range of IP addresses of the computers from which the connection will be made, given as [IP address/Mask]; in this case, it represents a single IP address.
- "md5" is the type of encryption for data transmission.