How can I connect to an Azure PostgreSQL database, from a remote machine?
Update 2. I can connect to the database from WSL/Ubuntu using sudo psql
, but I can't using plain psql
. So it's a permissions issue somewhere...
Update. I've discovered I can connect from the remote machine using PgAdmin4, but I can't connect using psql. So I want to know: how should I connect using psql?
Original question. I can connect to it using psql
from a VM inside Azure, so I know the database is up and accepting connections.
But when I try to connect from my home machine, using exactly the same psql
command, it fails:
psql --user=UUU --host=HHH DB
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
More information... On the Azure database's "Connection Security" blade, I have
- added a firewall rule with start IP=0.0.0.0 and end IP=255.255.255.255
- set "enforce SSL connection" to disabled
- turned on "allow access to Azure services".
My home machine is running Windows+WSL, and I'm trying to connect from WSL / Ubuntu 18.04
using psql version 10.11. I run into the same problem whether I try to connect from home or from work, and I'm not blocking any outgoing ports (that I know of).
The database is running PostgreSQL 10.
When I connect (successfully) from an Azure VM, using psql
10.10, it looks like this:
psql --user=UUU --host=HHH DB
Password for user UUU:
psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)