How to access PotgreSQL database with VPN

Rafael Gonçalves 0 Reputation points
2023-02-16T21:16:05.2666667+00:00

Hello! I want to be able to access my DB from any (and only) computer connected with a VPN (that means followed this Microsoft tutorial).

I've created an "Azure DB for PostgreSQL", followed the instructions, the connection with the VPN was successful, but the connection via Python, Azure Data Studio, Power BI or psql CLI does not work.

My vnet structure is the following:

aaa

For example, my Python code is something like:

user = 'admin'
password = 'admin'
host = '10.0.1.0'
port = '5432'
database = 'postgres'

engine = sqlalchemy.create_engine(
    f'postgresql://{user}:{password}@{host}:{port}/{database}?sslmode=require')
conn = engine.connect()

What am I missing here? Do I need any extra subnetworks or something like that?

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

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2023-02-20T21:11:12.44+00:00

    Hi,@Rafael Gonçalves Welcome to the Microsoft Q&A platform, thanks for posting the question

    Have you followed the prerequisites from this document if you are trying to connect from VNET.

    Also please follow this document on using python to connect Postgres flexible server.

    When you are trying to connect from Azure Data studio what is the error you get can you share the screenshot soi can better assist you?

    Regards

    Geetha


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.