8
votes

When trying to connect to my postgres server in Azure from psql client, I get the following error, even though I am using the correct username. How can I fix this?

psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username@hostname> format.

2

2 Answers

12
votes

As noted in the error text, you are required to follow the <username@hostname> format when trying to connect to postgresql server, whether you are doing it from psql client or using pgadmin. Using <username@hostname> format instead of just <username> should get rid of the error.

Read the quick-start documents for Azure portal and CLI to understand more about how to create and configure your postgres server.

5
votes

The @ sign in username works fine for objects but not connect strings. According to URI RFC-3986 username allows hex encoding. So replace the @ with %40. user@host:pw@fullhost becomes user%40host:pw@fullhost