Server closes connection unexpectedly when connecting to Azure Postgres

时光怂恿深爱的人放手 提交于 2020-05-13 07:29:25

问题


I'm trying to connect to Azure Postgresql using psql from my local machine and get the following error:

$ psql "host=username.postgres.database.azure.com port=5432 dbname=postgres user=username@domain password=mypassword sslmode=require"
psql: error: could not connect to server: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.

Local Postgres version: 12.1, Azure Postgres database version: 10, macOS Majove.

This issue only recently started after I reinstalled Postgres using Homebrew. I have no issues running $ psql --host=localhost.

I've tried installing postgresql@10 with homebrew so that when I run psql I get the message psql (12.1, server 10.11). But when I attempt to log into Azure Postgres I get the same error as above.

I'm fairly new to Postgres and Azure and would appreciate any suggestions.

Update:

Thanks for the comments and feedback.

I properly installed Postgres 10 with Homebrew and linked it to fix the problem.

$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10

I can now access the Azure database as expected.


回答1:


In this case, you could install the PostgreSQL Client for macOS with Homebrew properly then link it as it will symlink all the tools into the /usr/local/bin directory.

To fix this issue, run the following commands:

$ brew services stop postgresql
$ brew install postgresql@10
$ brew services start postgresql@10
$ brew link --overwrite --force postgresql@10

Ref: https://www.compose.com/articles/postgresql-tips-installing-the-postgresql-client/



来源:https://stackoverflow.com/questions/59548242/server-closes-connection-unexpectedly-when-connecting-to-azure-postgres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!