Archon icon indicating copy to clipboard operation
Archon copied to clipboard

How to use supabase locally hosted

Open JaMa-95 opened this issue 3 months ago • 17 comments

Could somebody explain me what i have to use for supabase url and service key when i host supabase locally? Tried a lot of different settings but nothing worked

SUPABASE_URL=
SUPABASE_SERVICE_KEY=

These are my supabase settings. Rest is stanard settings

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

Thanks a lot

JaMa-95 avatar Sep 10 '25 19:09 JaMa-95

This is what I use. Pull the values from the Supabase .env file.

SUPABASE_URL= {API_EXTERNAL_URL}
SUPABASE_SERVICE_KEY= {SERVICE_ROLE_KEY}

tazmon95 avatar Sep 10 '25 19:09 tazmon95

I use the exact same and get a "Backend Service Startup Failure". Do i need to do some additional configuration in supabase?

JaMa-95 avatar Sep 10 '25 19:09 JaMa-95

You need to runt he migration migration/complete_setup.sql

see README.md and follow the steps

Wirasm avatar Sep 12 '25 12:09 Wirasm

Also @JaMa-95 - your Supabase URL for self hosted supabase is generally: http://host.docker.internal:8000

coleam00 avatar Sep 12 '25 22:09 coleam00

If supabase is not on the local docker network, Archon is going to want SSL with a real cert.

joshuazick1 avatar Sep 12 '25 23:09 joshuazick1

@joshuazick1 how you come to that conclusion?

Its working fine for me without. I use Archon locally installed on my deskotp and also on my Proxmox Server with Linux VMs + Another Proxmox Linux Container where my Supabase is hosted. Works fine without any SSL Certs.

leex279 avatar Sep 13 '25 20:09 leex279

My findings may be from an older version. I had mine set up in two LXC containers on the same subnet. When I had http://$supabase_ip:8000 the logs for archon-server said that it wasn't a local connection and required ssl, when https://$supabase_ip:8443 it wouldn't start because it didn't like the self signed cert.

joshuazick1 avatar Sep 14 '25 19:09 joshuazick1

@joshuazick1 could you confirm if you are still experiencing this issue or if the recommendation from @leex279 solved it for you?

Wirasm avatar Sep 17 '25 10:09 Wirasm

I could not get it running yet. When using docker i tried those two endpoint:

http://localhost:8000/ http://host.docker.internal:8000/

I now used the cli version and have this environment: ` ~/bin/supabase status rbenv:3.3.0 Stopped services: [supabase_imgproxy_archon supabase_pooler_archon] supabase local development setup is running.

     API URL: http://127.0.0.1:54321
 GraphQL URL: http://127.0.0.1:54321/graphql/v1

S3 Storage URL: http://127.0.0.1:54321/storage/v1/s3 DB URL: postgresql://postgres:[email protected]:54322/postgres Studio URL: http://127.0.0.1:54323 Inbucket URL: http://127.0.0.1:54324 JWT secret: super-secret-jwt-token-with-at-least-32-characters-long anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0 service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU S3 Access Key: 625729a08b95bf1b7ff351a663f3a23c S3 Secret Key: 850181e4652dd023b7a98c58ae0d2d34bd487ee0cc3254aed6eda37307425907 S3 Region: local `

But then using this data it still does not work: SUPABASE_URL=http://localhost:54323 SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU

Not sure what i am doing wrong. I also tried http://localhost:54321

JaMa-95 avatar Sep 18 '25 15:09 JaMa-95

I'm having the same problem - using CentOS 9 stream and supabase running in docker. I can access supabase in my browser on port 8000 and have the supabase setup sql from archon.

The problem seems to be with the host's iptables preventing access from one docker container to the other. If I stop iptables, stop all the containers, restart docker, start the containers, then archon can connect to supabase. This is puzzling as I can access supabase with my lan ip. Perhaps some masquerade rule is needed here.

HotPepperDaddy avatar Sep 18 '25 18:09 HotPepperDaddy

I have it working here. I had to add a network in supabase's docker-compose.yml, add it to the services (I added to all of them but I suspect that I don't). Since archon depends on supabase I first added it there.

--- ../supabase/docker/docker-compose.yml       2025-09-18 10:33:46.892913202 -0300
+++ docker-compose.yml  2025-09-19 10:03:19.957819858 -0300
@@ -13,6 +13,8 @@
     container_name: supabase-studio
     image: supabase/studio:2025.06.30-sha-6f5982d
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     healthcheck:
       test:
         [
@@ -56,6 +58,8 @@
     ports:
       - ${KONG_HTTP_PORT}:8000/tcp
       - ${KONG_HTTPS_PORT}:8443/tcp
+    networks:
+      - archon-supabase-shared
     volumes:
       # https://github.com/supabase/supabase/issues/12661
       - ./volumes/api/kong.yml:/home/kong/temp.yml:ro,z
@@ -81,6 +85,8 @@
     container_name: supabase-auth
     image: supabase/gotrue:v2.177.0
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     healthcheck:
       test:
         [
@@ -164,6 +170,8 @@
     container_name: supabase-rest
     image: postgrest/postgrest:v12.2.12
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     depends_on:
       db:
         # Disable this if you are using an external Postgres database
@@ -188,6 +196,8 @@
     container_name: realtime-dev.supabase-realtime
     image: supabase/realtime:v2.34.47
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     depends_on:
       db:
         # Disable this if you are using an external Postgres database
@@ -233,6 +243,8 @@
     container_name: supabase-storage
     image: supabase/storage-api:v1.25.7
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     volumes:
       - ./volumes/storage:/var/lib/storage:z
     healthcheck:
@@ -276,6 +288,8 @@
     container_name: supabase-imgproxy
     image: darthsim/imgproxy:v3.8.0
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     volumes:
       - ./volumes/storage:/var/lib/storage:z
     healthcheck:
@@ -298,6 +312,8 @@
     container_name: supabase-meta
     image: supabase/postgres-meta:v0.91.0
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     depends_on:
       db:
         # Disable this if you are using an external Postgres database
@@ -316,6 +332,8 @@
     container_name: supabase-edge-functions
     image: supabase/edge-runtime:v1.69.6
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     volumes:
       - ./volumes/functions:/home/deno/functions:Z
     depends_on:
@@ -340,6 +358,8 @@
     container_name: supabase-analytics
     image: supabase/logflare:1.14.2
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     ports:
       - 4000:4000
     # Uncomment to use Big Query backend for analytics
@@ -389,6 +409,8 @@
     container_name: supabase-db
     image: supabase/postgres:15.8.1.060
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     volumes:
       - ./volumes/db/realtime.sql:/docker-entrypoint-initdb.d/migrations/99-realtime.sql:Z
       # Must be superuser to create event trigger
@@ -446,6 +468,8 @@
     container_name: supabase-vector
     image: timberio/vector:0.28.1-alpine
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     volumes:
       - ./volumes/logs/vector.yml:/etc/vector/vector.yml:ro,z
       - ${DOCKER_SOCKET_LOCATION}:/var/run/docker.sock:ro,z
@@ -477,8 +501,10 @@
     container_name: supabase-pooler
     image: supabase/supavisor:2.5.7
     restart: unless-stopped
+    networks:
+      - archon-supabase-shared
     ports:
-      - ${POSTGRES_PORT}:5432
+      - ${POSTGRES_PORT}:5433
       - ${POOLER_PROXY_PORT_TRANSACTION}:6543
     volumes:
       - ./volumes/pooler/pooler.exs:/etc/pooler/pooler.exs:ro,z
@@ -528,3 +554,9 @@
 
 volumes:
   db-config:
+
+networks:
+   archon-supabase-shared:
+     driver: bridge
+     name: archon-supabase-shared
+

Nevermind the postgres port change, I had to do that as it's also running locally.

Then I added that network to archon's docker-compose.yml as external then added it to archon's services.

diff --git a/docker-compose.yml b/docker-compose.yml
index f15be92..c63d2ec 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -30,6 +30,7 @@ services:
       - AGENTS_ENABLED=${AGENTS_ENABLED:-false}
     networks:
       - app-network
+      - archon-supabase-shared
     volumes:
       - /var/run/docker.sock:/var/run/docker.sock # Docker socket for MCP container control
       - ./python/src:/app/src # Mount source code for hot reload
@@ -88,6 +89,7 @@ services:
       - ARCHON_AGENTS_PORT=${ARCHON_AGENTS_PORT:-8052}
     networks:
       - app-network
+      - archon-supabase-shared
     depends_on:
       archon-server:
         condition: service_healthy
@@ -131,6 +133,7 @@ services:
       - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181}
     networks:
       - app-network
+      - archon-supabase-shared
     healthcheck:
       test:
         [
@@ -160,6 +163,7 @@ services:
       - VITE_SHOW_DEVTOOLS=${VITE_SHOW_DEVTOOLS:-false}
     networks:
       - app-network
+      - archon-supabase-shared
     healthcheck:
       test: ["CMD", "curl", "-f", "http://localhost:3737"]
       interval: 30s
@@ -175,3 +179,6 @@ services:
 networks:
   app-network:
     driver: bridge
+  archon-supabase-shared:
+    external: true
+    name: archon-supabase-shared

Then in my .env for archon I specified the supabase url as http://kong:8000.

As someone else stated, there's an https error since archon think's that's an external url and insists on https. I commented out that line.

diff --git a/python/src/server/config/config.py b/python/src/server/config/config.py
index 34284c1..0313354 100644
--- a/python/src/server/config/config.py
+++ b/python/src/server/config/config.py
@@ -127,7 +127,7 @@ def validate_supabase_url(url: str) -> bool:
             pass
 
         # If not a local host or private IP, require HTTPS
-        raise ConfigurationError(f"Supabase URL must use HTTPS for non-local environments (hostname: {hostname})")
+        #raise ConfigurationError(f"Supabase URL must use HTTPS for non-local environments (hostname: {hostname})")
 
     if not parsed.netloc:
         raise ConfigurationError("Invalid Supabase URL format")

I don't know if there's an easier way or a trick with iptables but that's how I solved this using docker only. Thoughts?

HotPepperDaddy avatar Sep 19 '25 13:09 HotPepperDaddy

@HotPepperDaddy Thanks a lot! Got it working thanks to your informations and thanks to ai :D

Here is a wrap up of what i hat to do.

A shared Docker bridge network was needed, that allows containers from both Archon and Supabase to communicate using Docker service names instead of localhost addresses.

Step 1: Add Shared Network to Supabase

1.1 Modify Supabase docker-compose.yml

Add the shared network to every service in your Supabase docker-compose.yml:

services:
  studio:
    container_name: supabase-studio
    image: supabase/studio:2025.06.30-sha-6f5982d
    restart: unless-stopped
    networks:
      - archon-supabase-shared  # Add this line
    # ... rest of service config

  kong:
    container_name: supabase-kong
    image: kong:2.8.1
    restart: unless-stopped
    networks:
      - archon-supabase-shared  # Add this line
    ports:
      - ${KONG_HTTP_PORT}:8000/tcp
    # ... rest of service config

  # Repeat for ALL services: auth, rest, realtime, storage,
  # imgproxy, meta, functions, analytics, db, vector, supavisor

1.2 Add Network Definition

At the end of the Supabase docker-compose.yml, add:

volumes:
  db-config:

networks:
   archon-supabase-shared:
     driver: bridge
     name: archon-supabase-shared

Step 2: Update Archon Configuration

2.1 Modify Archon docker-compose.yml

Add the shared network to every service in Archon's docker-compose.yml:

services:
  archon-server:
    # ... existing config
    networks:
      - app-network
      - archon-supabase-shared  # Add this line
    # ... rest of config

  archon-mcp:
    # ... existing config
    networks:
      - app-network
      - archon-supabase-shared  # Add this line
    # ... rest of config

  # Repeat for archon-agents and archon-frontend

2.2 Add External Network Reference

At the end of Archon's docker-compose.yml:

networks:
  app-network:
    driver: bridge
  archon-supabase-shared:
    external: true
    name: archon-supabase-shared

Step 3: Update Archon Environment

3.1 Modify Archon .env File

# Change from localhost to Docker service name
SUPABASE_URL=http://kong:8000

# Use the SERVICE_ROLE_KEY from your local Supabase .env file
SUPABASE_SERVICE_KEY=your-local-supabase-service-role-key

3.2 Fix HTTPS Validation

In python/src/server/config/config.py, update the validation function:

# Around line 129, replace the existing validation with:
# Allow Docker container hostnames (common service names)
docker_hostnames = ['kong', 'supabase-kong', 'postgres', 'supabase-db']
if hostname in docker_hostnames:
    return True

# If not a local host or private IP, require HTTPS
raise ConfigurationError(f"Supabase URL must use HTTPS for non-local environments (hostname: {hostname})")

Step 4: Start Services

4.1 Start Supabase First

cd ~/supabase-project
docker compose up -d

Wait for all services to become healthy (check with docker compose ps).

4.2 Start Archon

cd ~/archon
docker compose up -d

Step 5: Verify Integration

5.1 Check Service Status

# Check Supabase services
cd ~/supabase-project && docker compose ps

# Check Archon services
cd ~/archon && docker compose ps

5.2 Test Connectivity

# Test Archon health (should show "ready":true)
curl http://localhost:8181/health

# Test UI accessibility
curl -I http://localhost:3737

# Test Supabase Kong gateway
curl -I http://localhost:8000  # Should return 401 (expected without auth)

Key Points

  • Service Discovery: Uses Docker's built-in DNS (kong:8000 instead of localhost:8000)
  • Network Isolation: Maintains security while allowing inter-container communication
  • External Network: Supabase creates the network, Archon references it as external
  • Order Matters: Start Supabase before Archon to ensure the shared network exists

JaMa-95 avatar Sep 20 '25 14:09 JaMa-95

I still dont see why these changes should be needed. It works without any for me.

localhost => yes thats not working from inside the container, you need to use "host.docker.internal:8000" to use the host-gatway and connect to other services which are also exposed to the host.

Maybe I miss something, but dont see something in archon missing to allow this is working properly (as it is for me)

leex279 avatar Sep 20 '25 14:09 leex279

What OS are you using? Do you have an iptables firewall running? From my understanding this has to do with docker's networking and an iptables firewall managed on the host system outside of docker. I still have a hunch this can be solved with the right iptables rule.

I still dont see why these changes should be needed. It works without any for me.

localhost => yes thats not working from inside the container, you need to use "host.docker.internal:8000" to use the host-gatway and connect to other services which are also exposed to the host.

Maybe I miss something, but dont see something in archon missing to allow this is working properly (as it is for me)

HotPepperDaddy avatar Sep 20 '25 15:09 HotPepperDaddy

I use it on Windows and also on my Proxmox Linux Server Containers (seperate Containers for Archon and Supabase, communication over the network)

leex279 avatar Sep 20 '25 15:09 leex279

Agree, can be firewall stuff, but this also should not need to change archon itself, instead it should be solveable in the firewall.

leex279 avatar Sep 20 '25 15:09 leex279

Running Zorin OS 17.3 Pro on a headless 2012 Intel Mac Mini6... installed Supabase locally with the folllowing parameters: API URL: http://127.0.0.1:54321 GraphQL URL: http://127.0.0.1:54321/graphql/v1 S3 Storage URL: http://127.0.0.1:54321/storage/v1/s3 DB URL: postgresql://postgres:[email protected]:54322/postgres Studio URL: http://127.0.0.1:54323 Inbucket URL: http://127.0.0.1:54324

Which of these do i place in archon's .env file for the parameter SUPABASE_URL? thank you.

Quasaur avatar Oct 06 '25 01:10 Quasaur