supabase: error connecting to server due to GSSAPI negotiation

Bug report

  • [ X] I confirm this is a bug with Supabase, not with my own application.
  • [ X ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When connecting via pooling the following error is thrown: psql: error: connection to server at "aws-0-ap-southeast-1.pooler.supabase.com" (52.77.146.31), port 6543 failed: received invalid response to GSSAPI negotiation:

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Previously when I first started the project a few days ago, this connection worked: psql -h aws-0-ap-southeast-1.pooler.supabase.com -p 6543 -d postgres -U postgres.rkijdoxezclpigxoeacp But suddenly, it doesn’t.

Only this works: psql -h db.rkijdoxezclpigxoeacp.supabase.co -p 5432 -d postgres -U postgres

Tried the connection URI method on my application with similar outcomes.

Tested that: curl -6 https://ifconfig.co/ip and curl -4 https://ifconfig.co/ip both return ip addresses.

Expected behavior

Previously it is expected that connecting via psql -h aws-0-ap-southeast-1.pooler.supabase.com -p 6543 -d postgres -U postgres.rkijdoxezclpigxoeacp worked.

Screenshots

Most of the settings are at default. Screenshot 2024-10-12 at 11 57 40 AM Screenshot 2024-10-12 at 11 57 45 AM Screenshot 2024-10-12 at 11 57 50 AM Screenshot 2024-10-12 at 11 57 58 AM

System information

  • OS: macOS
  • Browser: Chrome / zshell
  • psql (PostgreSQL) 17.0 (Homebrew)

Additional context

Add any other context about the problem here.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 18

Most upvoted comments

If anyone ran into this, I found this SO post useful as it seems you need to be using Postgres 16 locally. Was able to fix with brew install postgresql@16 and brew link --overwrite postgresql@16

GSSAPI Negotiation Error in Supabase PostgreSQL Connections (SOLUTION)

Problem

You may encounter:

connection to server at "<host>" (<IP>), port <port> failed: received invalid response to GSSAPI negotiation

This occurs due to GSSAPI encryption incompatibility with Supabase’s pooler.


Solution

Add gssencmode=disable to your connection settings.

Connection Examples

Django

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'postgres',
        'USER': '<user>',
        'PASSWORD': '<password>',
        'HOST': 'aws-<region>.pooler.supabase.com',
        'PORT': '6543',
        'OPTIONS': {'gssencmode': 'disable'},
        'CONN_MAX_AGE': 500,
    }
}

SQLAlchemy

engine = create_engine("postgresql+psycopg2://<user>:<password>@aws-<region>.pooler.supabase.com:6543/<dbname>?gssencmode=disable")

psql Command

psql "host=aws-<region>.pooler.supabase.com port=6543 dbname=postgres user=<user> password=<password> gssencmode=disable"

Upgrade PostgreSQL Client

Update PostgreSQL client to version 16+:

brew install postgresql@16
brew link --overwrite postgresql@16
psql -V

References

I fixed this issue on my system by upgrading postgreSQL 14.5 to 17.2. I’m on MacOS 15.2 (24C101) and using homebrew.

> brew install postgresql@17
> psql -V
psql (PostgreSQL) 17.2 (Homebrew)

followed @NestorXX-XX suggestion (using psql [host=...] and it worked for me

Even after upgrading PostgreSQL to version 16, your system might still be using older versions internally.

One reliable solution is to remove all PostgreSQL versions except version 16 - this approach resolved the issue in my environment.

Important: If you have existing databases, make sure to backup your data before proceeding.

well still got the same issue as above notihing works