How to configure PostgreSQL to accept all incoming connections WINDOWS

1. SETTING PG_HBA.CONF

Just use 0.0.0.0/0.

host    all             all             0.0.0.0/0            md5

Make sure the listen_addresses in postgresql.conf (or ALTER SYSTEM SET) allows incoming connections on all available IP interfaces.

listen_addresses = '*'

After the changes you have to reload the configuration. One way to do this is execute this SELECT as a superuser.

SELECT pg_reload_conf();

Note: to change listen_addresses, a reload is not enough, and you have to restart the server.


2. RESTART POSTGRES SERVICES

  • Press Windows key + R, 'RUN' box will appear.
  • Type services. ...
  • Services window will open, search for postgresql-13. ...
  • Right-click on the postgresql-13 and click on the restart option.
  • The services will restart now.
  • This is how we can restart PostgreSQL services in windows machines.
3. Open Windows Firewall Port
AND ADD POSTGRESQL INTO WINDOWS FIREWALL INBOUNDS RULE

Does your PostgreSQL database run on a Windows server with firewall enabled?

In this case you can just turn off the firewall for a first test in Control Panel -> Systems and Security -> Windows Firewall -> Turn Windows Firewall on or off.

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
  • Action: Allow the connection
  • When does this rule apply: Domain, Private and Public (all three checked)
  • Name: "PostgreSQL Incoming"

No comments:

Powered by Blogger.