Command-line connection with VPN to remote PostgreSQL fails, other apps work
1
vote
0
answers
772
views
I am trying to connect to PostgreSQL database hosted on Azure programmatically.
I am able to do so using apps like [PgAdmin](https://www.pgadmin.org) or [Postico](https://eggerapps.at/postico/) . However, the connection does not work with
psql
or python
. I have the error :
psql: error: could not connect to server: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I am using a VPN (GlobalProtect v5.1.5-20) on MacOS 10.15.7. If I turn the VPN off and reboot my computer, the exact same psql
command does work. Therefore, I don't think it's related to the database server.
My main issue is that I don't know where to look at in order to debug.
What I've done so far:
- Checked the log of Postgres server: can't see my connections attempts.
- Checked pg_stat_activity
table and can't see any connections from my IP (except the one made with Postico)
- Checked with LittleSnitch whether python
/ psql
were able to connect to server. It seems that is the case.
- UPDATE: Connecting to Postgres db from a Docker container running locally does work (with or without VPN).
Any thoughts ?
UPDATE 1, my routing tables
* with VPN
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 10.12.24.32 UGSc utun2
default 192.168.0.1 UGScI en0
10.12.16.1 10.12.24.32 UGHS utun2
10.12.24.32 10.12.24.32 UHr utun2
10.12.24.32/32 link#18 UCS utun2
66.159.218.152 192.168.0.1 UGHS en0
127 127.0.0.1 UCS lo0
127.0.0.1 127.0.0.1 UH lo0
169.254 link#6 UCS en0 !
169.254.169.254 link#6 UHLSW en0 !
192.168.0 link#6 UCS en0 !
192.168.0.1/32 link#6 UCS en0 !
192.168.0.1 f4:6b:ef:4c:94:c4 UHLWIir en0 946
192.168.0.5 f4:6b:ef:4c:94:c5 UHLWIi en0 450
192.168.0.10 3c:15:c2:c5:50:4c UHLWI en0 1197
192.168.0.13 d4:a3:3d:5d:30:f8 UHLWI en0 577
192.168.0.22/32 link#6 UCS en0 !
192.168.0.24 46:c5:cd:a2:1e:32 UHLWIi en0 1182
192.168.0.28 8a:a:f8:f7:a2:d4 UHLWI en0 191
224.0.0/4 link#18 UmCS utun2
224.0.0/4 link#6 UmCSI en0 !
224.0.0.251 1:0:5e:0:0:fb UHmLWI en0
255.255.255.255/32 link#18 UCS utun2
255.255.255.255/32 link#6 UCSI en0 !
* without VPN
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.0.1 UGSc en0
127 127.0.0.1 UCS lo0
127.0.0.1 127.0.0.1 UH lo0
169.254 link#6 UCS en0 !
169.254.169.254 link#6 UHLSW en0 !
192.168.0 link#6 UCS en0 !
192.168.0.1/32 link#6 UCS en0 !
192.168.0.1 f4:6b:ef:4c:94:c4 UHLWIir en0 956
192.168.0.5 f4:6b:ef:4c:94:c5 UHLWIi en0 460
192.168.0.10 3c:15:c2:c5:50:4c UHLWI en0 587
192.168.0.13 d4:a3:3d:5d:30:f8 UHLWI en0 587
192.168.0.22/32 link#6 UCS en0 !
192.168.0.24 46:c5:cd:a2:1e:32 UHLWIi en0 1192
192.168.0.28 8a:a:f8:f7:a2:d4 UHLWIi en0 201
224.0.0/4 link#6 UmCS en0 !
255.255.255.255/32 link#6 UCS en0 !
Asked by ldc
(121 rep)
Nov 10, 2020, 09:24 AM
Last activity: Dec 1, 2020, 09:14 AM
Last activity: Dec 1, 2020, 09:14 AM