supabase: Self-Hosted dashboard stuck on `Connecting to Default Project`.

    I tried @karouvirae `docker-compose.yml` file and that did not work, I received errors from `auth`, `rest`, `realtime`, and `storage`

I tried both the following repositories and none of them worked. https://github.com/supabase-community/supabase-traefik https://github.com/supabase/supabase/tree/master/docker

First off, the unofficial Traefik setup that is supported by the community is outdated. The main self-hosting guide containers all work, although the Dashboard gets stuck, and I need to get this running as soon as possible.

I even found the following issue about it: https://github.com/supabase/supabase/issues/8721

Does this mean that self-hosting is currently not possible with the bug introduced in the above issue? I have made a help post about this in the Supabase Official discord, and so far no one has responded.

In the r/Supabase Reddit, there is a similar post. https://www.reddit.com/r/Supabase/comments/ycwude/comment/iuwa3az/?utm_source=share&utm_medium=web2x&context=3

I tried changing the following .env variables but no luck.

SITE_URL
API_EXTERNAL_URL
PUBLIC_REST_URL

Sadly I have been working on this for over 12 hours, and this is my very first experience with Supabase, a very horrible one at that.

_Originally posted by @NorkzYT in https://github.com/supabase/supabase/issues/4934#issuecomment-1302603468_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 38 (17 by maintainers)

Most upvoted comments

I’m the op of that issue on Reddit. Still no fix. It’s not really an issue with the dashboard, it’s an issue with the Database not connecting. None of the CLI will work either, because things like Auth are still stored in the Database which won’t connect. I followed the same guides as the first time I successfully self-hosted supabase so I’m sure it’s an issue with the update. As you’ve seen, I posted an issue on GitHub and Reddit over 10 days ago but got no support or help. I guess the expectation with self-hosting is that you are a developer who can fix these detrimental errors yourself instead of the Supabase team. This also came at the same time as the package updates (Flutter and JS), which were initially unannounced and made a lot of unexplained changes, so that might be a factor.

@NorkzYT

Looking at your .env, I see sub.domain.com for all of the URL’s even though they have different ports and paths. Do each of them have a unique subdomain that points to the corresponding port and path? If it’s just one subdomain that points to the server IP, you would need to specify ports at the end of each URL. For example: SITE_URL=https://sub.domain.com:3000. If I were you, I would try to change the URLs to the server IP and the corrects ports to make sure that’s not the issue.

@daffodilistic

I was now able to get back to work with this issue.

I am still having issues, I even restarted with the new commits made to the docker-compose.yml file 16 hours ago. I believe my issues are only coming from the .env file since there are no errors in the docker container logs.

The following contents are the Supabase docker-compose.yml file.

# Usage
#   Start:          docker-compose up
#   With helpers:   docker-compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml up
#   Stop:           docker-compose down
#   Destroy:        docker-compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml down -v --remove-orphans

version: "3.8"
services:

#####################################################################################################################

  studio:
    container_name: supabase-studio
    image: supabase/studio:0.22.08
    restart: unless-stopped
    ports:
      - ${STUDIO_PORT}:3000/tcp
    environment:
      STUDIO_PG_META_URL: http://meta:8080
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

      DEFAULT_ORGANIZATION: ${STUDIO_DEFAULT_ORGANIZATION}
      DEFAULT_PROJECT: ${STUDIO_DEFAULT_PROJECT}

      SUPABASE_URL: http://kong:8000
      SUPABASE_PUBLIC_URL: ${SUPABASE_PUBLIC_URL}
      # Kept for backwards compatibility with studio:0.22.08
      SUPABASE_REST_URL: ${API_EXTERNAL_URL}/rest/v1/
      SUPABASE_ANON_KEY: ${ANON_KEY}
      SUPABASE_SERVICE_KEY: ${SERVICE_ROLE_KEY}
    networks:
      - proxy

#####################################################################################################################

  kong:
    container_name: supabase-kong
    image: kong:2.8.1
    restart: unless-stopped
    ports:
      - ${KONG_HTTP_PORT}:8000/tcp
      - ${KONG_HTTPS_PORT}:8443/tcp
    environment:
      KONG_DATABASE: "off"
      KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml
      # https://github.com/supabase/cli/issues/14
      KONG_DNS_ORDER: LAST,A,CNAME
      KONG_PLUGINS: request-transformer,cors,key-auth,acl
      KONG_NGINX_PROXY_PROXY_BUFFER_SIZE: 160k
      KONG_NGINX_PROXY_PROXY_BUFFERS: 64 160k
    volumes:
      - ./volumes/api:/var/lib/kong:ro
    networks:
      - proxy

#####################################################################################################################

  auth:
    container_name: supabase-auth
    image: supabase/gotrue:v2.31.0
    depends_on:
      db: # Disable this if you are using an external Postgres database
        condition: service_healthy
    restart: unless-stopped
    environment:
      GOTRUE_API_HOST: 0.0.0.0
      GOTRUE_API_PORT: 9999
      API_EXTERNAL_URL: ${API_EXTERNAL_URL}

      GOTRUE_DB_DRIVER: postgres
      GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:${POSTGRES_PASSWORD}@db:5432/postgres

      GOTRUE_SITE_URL: ${SITE_URL}
      GOTRUE_URI_ALLOW_LIST: ${ADDITIONAL_REDIRECT_URLS}
      GOTRUE_DISABLE_SIGNUP: ${DISABLE_SIGNUP}

      GOTRUE_JWT_ADMIN_ROLES: service_role
      GOTRUE_JWT_AUD: authenticated
      GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated
      GOTRUE_JWT_EXP: ${JWT_EXPIRY}
      GOTRUE_JWT_SECRET: ${JWT_SECRET}

      GOTRUE_EXTERNAL_EMAIL_ENABLED: ${ENABLE_EMAIL_SIGNUP}
      GOTRUE_MAILER_AUTOCONFIRM: ${ENABLE_EMAIL_AUTOCONFIRM}
      # GOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED: true
      # GOTRUE_SMTP_MAX_FREQUENCY: 1s
      GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_ADMIN_EMAIL}
      GOTRUE_SMTP_HOST: ${SMTP_HOST}
      GOTRUE_SMTP_PORT: ${SMTP_PORT}
      GOTRUE_SMTP_USER: ${SMTP_USER}
      GOTRUE_SMTP_PASS: ${SMTP_PASS}
      GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_NAME}
      GOTRUE_MAILER_URLPATHS_INVITE: ${MAILER_URLPATHS_INVITE}
      GOTRUE_MAILER_URLPATHS_CONFIRMATION: ${MAILER_URLPATHS_CONFIRMATION}
      GOTRUE_MAILER_URLPATHS_RECOVERY: ${MAILER_URLPATHS_RECOVERY}
      GOTRUE_MAILER_URLPATHS_EMAIL_CHANGE: ${MAILER_URLPATHS_EMAIL_CHANGE}

      GOTRUE_EXTERNAL_PHONE_ENABLED: ${ENABLE_PHONE_SIGNUP}
      GOTRUE_SMS_AUTOCONFIRM: ${ENABLE_PHONE_AUTOCONFIRM}
      MFA_ENABLED: ${MFA_ENABLED}
    networks:
      - proxy

#####################################################################################################################

  rest:
    container_name: supabase-rest
    image: postgrest/postgrest:v9.0.1.20220717
    depends_on:
      db: # Disable this if you are using an external Postgres database
        condition: service_healthy
    restart: unless-stopped
    environment:
      PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@db:5432/postgres
      PGRST_DB_SCHEMAS: ${PGRST_DB_SCHEMAS}
      PGRST_DB_ANON_ROLE: anon
      PGRST_JWT_SECRET: ${JWT_SECRET}
      PGRST_DB_USE_LEGACY_GUCS: "false"
    networks:
      - proxy

#####################################################################################################################

  realtime:
    container_name: supabase-realtime
    image: supabase/realtime:v0.25.1
    depends_on:
      db: # Disable this if you are using an external Postgres database
        condition: service_healthy
    restart: unless-stopped
    environment:
      DB_HOST: ${POSTGRES_HOST}
      DB_PORT: ${POSTGRES_PORT}
      DB_NAME: ${POSTGRES_DB}
      DB_USER: supabase_admin
      DB_PASSWORD: ${POSTGRES_PASSWORD}
      DB_SSL: "false"
      PORT: 4000
      JWT_SECRET: ${JWT_SECRET}
      REPLICATION_MODE: RLS
      REPLICATION_POLL_INTERVAL: 100
      SECURE_CHANNELS: "true"
      SLOT_NAME: supabase_realtime_rls
      TEMPORARY_SLOT: "true"
    command: >
      bash -c "./prod/rel/realtime/bin/realtime eval Realtime.Release.migrate
      && ./prod/rel/realtime/bin/realtime start"
    networks:
      - proxy

#####################################################################################################################

  storage:
    container_name: supabase-storage
    image: supabase/storage-api:v0.21.4
    depends_on:
      db: # Disable this if you are using an external Postgres database
        condition: service_healthy
      rest:
        condition: service_started
    restart: unless-stopped
    environment:
      ANON_KEY: ${ANON_KEY}
      SERVICE_KEY: ${SERVICE_ROLE_KEY}
      POSTGREST_URL: http://rest:3000
      PGRST_JWT_SECRET: ${JWT_SECRET}
      DATABASE_URL: postgres://supabase_storage_admin:${POSTGRES_PASSWORD}@db:5432/postgres
      FILE_SIZE_LIMIT: 52428800
      STORAGE_BACKEND: file
      FILE_STORAGE_BACKEND_PATH: /var/lib/storage
      TENANT_ID: stub
      # TODO: https://github.com/supabase/storage-api/issues/55
      REGION: stub
      GLOBAL_S3_BUCKET: stub
    volumes:
      - ./volumes/storage:/var/lib/storage
    networks:
      - proxy

#####################################################################################################################

  meta:
    container_name: supabase-meta
    image: supabase/postgres-meta:v0.52.1
    depends_on:
      db: # Disable this if you are using an external Postgres database
        condition: service_healthy
    restart: unless-stopped
    environment:
      PG_META_PORT: 8080
      PG_META_DB_HOST: ${POSTGRES_HOST}
      PG_META_DB_PORT: ${POSTGRES_PORT}
      PG_META_DB_NAME: ${POSTGRES_DB}
      PG_META_DB_USER: supabase_admin
      PG_META_DB_PASSWORD: ${POSTGRES_PASSWORD}
    networks:
      - proxy

#####################################################################################################################


  # Comment out everything below this point if you are using an external Postgres database
  db:
    container_name: supabase-db
    image: supabase/postgres:14.1.0.89
    healthcheck:
      test: pg_isready -U postgres -h localhost
      interval: 5s
      timeout: 5s
      retries: 10
    command:
      - postgres
      - -c
      - config_file=/etc/postgresql/postgresql.conf
      - -c
      - log_min_messages=fatal # prevents Realtime polling queries from appearing in logs
    restart: unless-stopped
    ports:
      - 3524:5432
    environment:
      POSTGRES_HOST: /var/run/postgresql
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - ./volumes/db/roles.sql:/docker-entrypoint-initdb.d/roles.sql
    networks:
      - proxy

#####################################################################################################################

networks:
  proxy:
    driver: bridge
    external: true

The following contains my .env file.

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

POSTGRES_PASSWORD=xxx
JWT_SECRET=xxx
ANON_KEY=xxx
SERVICE_ROLE_KEY=xxx

############
# Database - You can change these to any PostgreSQL database that has logical replication enabled.
############

POSTGRES_HOST=db
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PORT=5432


############
# API Proxy - Configuration for the Kong Reverse proxy.
############

KONG_HTTP_PORT=8007
KONG_HTTPS_PORT=8447


############
# API - Configuration for PostgREST.
############

PGRST_DB_SCHEMAS=public,storage,graphql_public


############
# Auth - Configuration for the GoTrue authentication server.
############

## General
SITE_URL=https://sub.domain.com
ADDITIONAL_REDIRECT_URLS=
JWT_EXPIRY=3600
DISABLE_SIGNUP=false
API_EXTERNAL_URL=https://sub.domain.com

## Mailer Config
MAILER_URLPATHS_CONFIRMATION="/auth/v1/verify"
MAILER_URLPATHS_INVITE="/auth/v1/verify"
MAILER_URLPATHS_RECOVERY="/auth/v1/verify"
MAILER_URLPATHS_EMAIL_CHANGE="/auth/v1/verify"

## Email auth
ENABLE_EMAIL_SIGNUP=true
ENABLE_EMAIL_AUTOCONFIRM=false
SMTP_ADMIN_EMAIL=xxx
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=xxx
SMTP_PASS=xxx
SMTP_SENDER_NAME=xxx

## Phone auth
ENABLE_PHONE_SIGNUP=true
ENABLE_PHONE_AUTOCONFIRM=true


############
# Studio - Configuration for the Dashboard
############

STUDIO_DEFAULT_ORGANIZATION=Brainstormr Organization
STUDIO_DEFAULT_PROJECT=Brainstormr

STUDIO_PORT=3529
MFA_ENABLED=false

# replace if you intend to use Studio outside of localhost
SUPABASE_PUBLIC_URL=https://sub.domain.com

If you are able to, talking in Discord would be much preferable to fix this issue as quickly as possible.

My Discord info. Norkz#2594

Update: I managed to wrangle Supabase for use with Caddy. This configuration might be a good starting point to study and apply for Traefik.

Caddyfile config:

studio.example.com {
        handle /rest/* {
		reverse_proxy host.docker.internal:8080 {
                        header_down  -Server
		}
	}

        handle {
                # Enforce HTTP Basic Auth just to get stuff working - should be hardened!
                basicauth * bcrypt {
                        admin <INSERT_HASHED_PASSWORD_HERE>
                }
                reverse_proxy host.docker.internal:3000 {
                        header_down  -Server
		}
	}
}

.env file config:

# KONG_HTTP_PORT can be changed if needed,
# just make sure it matches up your reverse proxy's config
KONG_HTTP_PORT=8080
SITE_URL=https://studio.example.com
# Not sure if this is used anywhere?
API_EXTERNAL_URL=http://172.31.6.7:8000
# NOTE using /rest/ doesn't work, you *must* use /rest/v1/
PUBLIC_REST_URL=https://studio.example.com/rest/v1/

Hope this helps.

I followed your steps and now with this pull I get an error from docker-compose up in the new directory:

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.storage.depends_on contains an invalid type, it should be an array
services.auth.depends_on contains an invalid type, it should be an array
services.meta.depends_on contains an invalid type, it should be an array
services.realtime.depends_on contains an invalid type, it should be an array
services.rest.depends_on contains an invalid type, it should be an array

Can you share some screenshots or errors that you’re seeing? It sounds like “Connecting to Default Project” is displayed somewhere (maybe in the studio?)

This is what the “Connecting to Default Project” message, yes it is in the studio: 2022-11-05_15-48