Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] - unable to connect to db using psql or pgadmin #161

Open
Justin-JHG opened this issue Feb 7, 2025 · 1 comment
Open

[HELP] - unable to connect to db using psql or pgadmin #161

Justin-JHG opened this issue Feb 7, 2025 · 1 comment

Comments

@Justin-JHG
Copy link

Justin-JHG commented Feb 7, 2025

I was running the demo in codespace

I followed the guide to export the token generated as password

export PGPASSWORD={"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI...........VPNUlKeXlxUjZqekRTNWlBYnBlNDJKdyJ9"}

and then run the following
$ psql -h $(azd env get-value POSTGRES_HOST) -U $(azd env get-value POSTGRES_USERNAME) -d $(azd env get-value POSTGRES_DATABASE) -p 5432

but getting this error:

psql: error: connection to server at "justin-test-3a*****bi-postgresql.postgres.database.azure.com" (172.177.167.194), port 5432 
failed: FATAL:  The access token has invalid format. 
Please ensure the token is passed exactly as returned by the authentication endpoint and retry.

connection to server at "justin-test-3a******zbi-postgresql.postgres.database.azure.com" (172.177.167.194), port 5432 
failed: FATAL:  no pg_hba.conf entry for host "20.227.141.210", user "adminupjcfh45d******" database "postgres", no encryption
@Justin-JHG Justin-JHG changed the title [help] - unable to connect to db using psql or pgadmin [HELP] - unable to connect to db using psql or pgadmin Feb 7, 2025
@Justin-JHG
Copy link
Author

I tried the following and it worked

export PGPASSWORD=$(az account get-access-token --resource-type oss-rdbms --query "[accessToken]" -o tsv)

ref: https://learn.microsoft.com/en-gb/azure/postgresql/flexible-server/how-to-configure-sign-in-azure-ad-authentication

not sure why the export PGPASSWORD={token} doesn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant