Supabase Docker's Realtime Health Check Returning 403

1 min

Preamble

Recently, I’ve been creating some tools at work to handle miscellaneous tasks, so I went ahead and set up Supabase to conveniently manage tables and quickly add edge functions.

Problem Encountered

Following the official Docker setup guide, after running it, the realtime container is persistently in an unhealthy state. Upon checking the logs, I found it’s calling the following endpoint:

http://localhost:4000/api/tenants/realtime-dev/health

then

19:51:53.178 request_id=GAPwPoYM16upnkEAAB8C [info] Sent 403 in 488µs

How to fix it

############
# Secrets
# YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION
############

POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password
JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q
DASHBOARD_USERNAME=supabase
DASHBOARD_PASSWORD=this_password_is_insecure_and_should_be_updated
SECRET_KEY_BASE=UpNVntn3cDxHJpq99YMc1T1AQgQpc8kfYTuRgBiYa15BLrx8etQoXz3gZv1/u2oq
VAULT_ENC_KEY=your-encryption-key-32-chars-min
PG_META_CRYPTO_KEY=your-encryption-key-32-chars-min

The above is from the official .env.example. Your ANON_KEY and SERVICE_ROLE_KEY both need to be JWTs (JSON Web Tokens) generated using the JWT_SECRET. Therefore, you can use JWT.IO to generate these tokens.

service_role_key 的 payload

{
  "role": "service_role",
  "iss": "發行者名稱",
  "exp": 1893387500
}

anon_key 的 payload

{
  "role": "anon",
  "iss": "發行者名稱",
  "iat": 1759988092,
  "exp": 1893387500
}

After updating these three keys like this, it will work correctly.

Comments

Loading comments...