1

I just wasted an hour of my life trying to figure out why pgAdminIII couldn't connect to the server on localhost. After trying config edits, starting/stopping the postgresql service, etc., I finally realized only one thing had changed since the last time I used pgAdminIII: I was connected to my VPN.

I'm no network wizard, so that's why I'm asking here: why can't I connect to PostgreSQL (localhost) when I'm actively connected to my VPN provider?

Bonus: what commands/steps can I use to show exactly why?


EDIT:

pg_hba.conf:

...
# CAUTION: Configuring the system for local "trust" authentication
# allows any local user to connect as any PostgreSQL user, including
# the database superuser.  If you do not trust all your local users,
# use another authentication method.


# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     chris                                trust
#host    replication     chris        127.0.0.1/32            trust
#host    replication     chris        ::1/128                 trust

OS X version: 10.12.6 (Sierra)

PostgreSQL version: 9.6.3

VPN provider: ExpressVPN

3
  • More info is required - including the connect info - mainly hostname (don't post password) used by pgAdminIII. A dump of your pg_hba.conf file and OS details would be useful. I suspect that OpenVPN is a red herring.
    – davidgo
    Commented Mar 6, 2018 at 23:23
  • @davidgo Added. Sorry about that, I posted without really thinking about config info. The Postgres installation is all default - I didn't change anything. And I'm using ExpressVPN, not OpenVPN. The localhost server is localhost:5432 (the default). Commented Mar 6, 2018 at 23:39
  • ExpressVPN is a provider - OpenVPN is a program. ExpressVPN uses OpenVPN. What error are you getting, and do you realise that your postgres config file allows anyone to connect to it from the local system without a password ? The problem is highly unlikely to be related to OpenVPN - but check that your hosts file maps localhost to 127.0.0.1 (or ::1/128) rather then another IP address which is not reachable via the LO interface. Also check if the VPN software is messing with your firewall rules - but this is unlikely
    – davidgo
    Commented Mar 7, 2018 at 1:33

1 Answer 1

0

I'm no networking wizard, so that's why I'm asking here: why can't I connect to PostgreSQL (localhost) when I'm actively connected to my VPN provider?

You have configured your PostgreSQL installation to only allow localhost connections.

what commands/steps can I use to show exactly why?

Modify pg_hba.conf to include an entry for your ExpressVPN IP address

host all all xxx.xxx.xxx.xxx trust

I do not suggest you give all local and database users who connect to your server using the VPN address access to your database. If you wanted that to be the case, you would change the xxx.xxx.xxx.xxx to your ExpressVPN IP address, and any user would be able to connect to your database server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .