Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access PostgreSQL Database Outside Local Network

I have a Windows 10 machine, and I would like to access a database which is set on another machine outside local network.

Is there any possibility of achieving that using postgresql?

Thank's a lot, and I'd appreciate your effort to help me overcome this situation.

like image 514
DiMis Avatar asked Apr 22 '26 01:04

DiMis


1 Answers

It is possible, provided that:

  1. The firewall of your local network allows outgoing connections to the PostgreSQL listen port (usually 5432).
  2. The firewall of the other network allows incoming connections to the PostgreSQL listen port (usually 5432).
  3. The firewall of the PostgreSQL server allows connection on its listen port (usually 5432).
  4. The PostgreSQL server is configured to accept network connections.

You can use a network scanner such as Nmap to test things, thing to do is to get a laptop on the customer's network, and scan from there. If you can connect to the PostgreSQL from an address on the same subnet, then you know there is nothing else needed on the PostgreSQL server, and so your attention need to be on the customer's firewall. This is where things can get difficult, and you'll need to work with whoever controls that firewall / router.

Chances are that the customer's network is on an RFC 1918 subnet. If this is the case the firewall / router will need to be configured to port forward like this:


public internet
       |
 ----public address--port nnn--
|                             |
|     firewall                |
|                             |
|-----rfc 1918 address--------|
          |     
          |  
          |  
 ----rfc 1918 address--port 5432--
|                                |
|     PostgreSQL server          |
|                                |
|--------------------------------|
like image 93
trajekolus Avatar answered Apr 25 '26 00:04

trajekolus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!