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 Windows1
Adding ?gssencmode=disable to the connection string worked for me:
import pyodbc from sqlalchemy import create_engine engine = create_engine(f'postgresql://{user}:{password}@localhost:5432/database_name?gssencmode=disable')