psycopg2.OperationalError: FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0

蓝咒 提交于 2020-03-15 07:59:26

问题


I'm using Macbook

Psycopg2 works well when connecting the localhost db (PostgreSQL on Mac). The error was raised when I tried to connect PostgreSQL db on a Windows10.

the following code is what I have for connection, the host is just the IP of the windows10

db= psycopg2.connect(database='dbname',user='username',password="secret",host="192.168.3.9",port="5432")

Errors:

  File "path/to/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0

Is this because of system compatibility or something else? I've tried other Windows machine and I got no luck to make it work. However, I was able to connect PostgreSQL on windows while I using Node.JS module pg


回答1:


1234.5679 is the special code sent by the client to request SSL-encrypted database connections, and support for that has been in PostgreSQL since commit e0e7daef6da in 1999. But your PostgreSQL cannot be that old, because support for protocol version 3.0 was not added before 2003.

Actually, from studying src/backend/postmaster/postmaster.c and reading the mailing list, this is a bug on the PostgreSQL server:

The client must be configured to try GSS authentication, and when the server rejects, it wants to negotiate an SSL connections, but the server doesn't expect that at this point; hence the error.

See the discussion here.

As a workaround, disable either GSS authentication or SSL negotiation on the client.




回答2:


Getting a similar error working with Laravel and Postgres. Solved it by putting this in my .env file: PGGSSENCMODE=disable



来源:https://stackoverflow.com/questions/59190010/psycopg2-operationalerror-fatal-unsupported-frontend-protocol-1234-5679-serve

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