Connecting to postgresql through VPN

Claborne, Daniel 1 Reputation point
2021-08-26T18:53:15.983+00:00

I have set up a Postgresql database and am trying to connect with Python/psql through a VPN. I am using the connection string of the form "host=myhost.postgres.database.azure.com port=5432 dbname=postgres user=user password=mypw sslmode=require"

In networking, I whitelist the ip range corresponding to the private network, but cannot connect as I can with an MSSQL-server database using the same whitelist. I get the error:

psql: error: could not connect to server: Operation timed out
Is the server running on host "<hostname>" (<hostip>) and accepting
TCP/IP connections on port 5432?

When disconnecting from the VPN an allowing all ip's I can connect with psql.

I'm not able to follow the language in this post: https://stackoverflow.com/questions/56127851/connect-to-azure-database-for-postgresql-through-vpn but it sounds like there may be no resolution to this?

Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. KalyanChanumolu-MSFT 8,321 Reputation points
    2021-08-27T07:58:55.447+00:00

    @Claborne, Daniel Thank you for reaching out.

    The answer on StackOverflow seems to be old and was posted before Azure Private Link was available.

    You can now Configure Private Link for Azure Database for PostgreSQL and Connect from an on-premises environment over VPN
    Detailed instructions are provided in the hyperlinks above.

    Please let us know if you face any issues or have further questions.

    ----------

    If an answer is helpful, please "Accept answer" or "Up-Vote" which might help other community members reading this thread.

    0 comments No comments