I want to configure PostgreSQL to accept connections only from a specified IP. It should not accept requests from any other IP.
As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.
The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 .
You can also connect to PostgreSQL database using pgAdmin GUI application. Connect to the database at localhost:5432 using the user name postgres and the password supplied. Now, double click on PostgreSQL 9.4 under the "Servers Groups". pgAdmin will ask you for a password.
The following pg_hba.conf allows local and specified Ip have privilege login, but reject others。
# TYPE DATABASE USER ADDRESS METHOD local all all trust host testdb testuser 192.168.1.1/32 md5 host all all 0.0.0.0/0 reject
The easiest way is to make PostgreSQL listen only on localhost
for incoming connections. The relevant parameter is listen_addresses
in postgresql.conf
. The doc is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With