name: rochasales-supabase-debug
description: Debug broker area tools not appearing on rochasalesseguros.com.br β self-hosted Supabase on VPS
category: devops
Skill: rochasales Supabase Self-Hosted Debug
Context
Rochasalesseguros.com.br uses a self-hosted Supabase on VPS (NOT Supabase Cloud).
The Supabase URL is https://xdexxwycztdqlvfnpgac.supabase.co β resolves to Kong on VPS port 8000.
The admin user tecrochasales@gmail.com id: 9b645fa9-c5ed-4537-a803-4b66d6e6b63d.
Problem
Tools in "Γrea do Corretor" not appearing. Kong returns {"message":"name resolution failed"} for /rest/v1/ routes.
Architecture (self-hosted Supabase on VPS)
`
VPS Port 443 β Nginx (frontend Next.js)
VPS Port 8000 β Kong API Gateway
βββ /auth/v1/ β GoTrue (auth service) port 9999
βββ /rest/v1/ β PostgREST port 3000
βββ /storage/v1/ β Storage service port 5000
VPS Port 5433 β PostgreSQL
`
Common Silent Failure: Container Defined But Not Running
THE #1 cause of API failures on this stack: PostgREST container is defined in docker-compose.yml but NOT running.
Symptoms:
- - Kong logs:
"name resolution failed"when accessing/rest/v1/* - - PostgREST not in
docker ps - - All REST API calls to
/rest/v1/fail silently - - Frontend shows "ferramentas nΓ£o aparecem" (tools not appearing)
- - Rochasalesseguros.com.br (broker area): Self-hosted on VPS, project ref
xdexxwycztdqlvfnpgac,/opt/rochasales - - ComercialRS (CRM): Supabase Cloud, project
dauftiqcvgaydddoxqhh,/var/www/comercialrs
Fix:
`bash
Check if PostgREST container exists (defined but not running = ps -a shows it)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "docker ps -a | grep -i rest"
Start it (from the dir where docker-compose.yml is)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "cd /docker/deploy-vps && docker compose up -d rest"
Verify it's up
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s http://localhost:8000/rest/v1/broker_links?select=id"
`
Why does this happen? The .env file at /docker/deploy-vps/.env is empty (no secrets). docker compose up -d rest may have been skipped initially, or the container was never restarted after a failure.
Quick Debug Commands (VPS)
`bash
Check all Supabase containers (look for "rest" β it's often missing)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "docker ps -a --format '{{.Names}} {{.Status}}' | grep -iE 'rest|postgrest|storage|db|auth|kong'"
Test Kong routes from VPS (Kong must be able to reach the backend)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s 'http://localhost:8000/rest/v1/'"
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s 'http://localhost:9999/health'"
Kong admin API
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s http://localhost:8001/services"
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s http://localhost:8001/routes"
Check Docker networks (PostgREST must be on same network as Kong)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "docker network ls && echo '---' && docker network inspect deploy-vps_default --format '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{\"\n\"}}{{end}}'"
Direct PostgREST test (if container exists with different name or on host)
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "curl -s http://localhost:3000/ || echo 'Port 3000 not responding'"
Check PostgREST process on host
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "ps aux | grep -i postgrest"
Check Kong logs
sshpass -p 'Marcia19671951@' ssh -o StrictHostKeyChecking=no root@31.97.243.106 "docker logs deploy-vps-kong-1 --tail 20 2>&1 | grep -i 'rest\|postgrest\|error\|fail'"
`
Key Files on VPS
`bash
Docker compose project (self-hosted Supabase) β THIS IS WHERE THE CONTAINERS ARE
/opt/rochasales/docker-compose.yml # DEFINITION (not where compose is run from)
/docker/deploy-vps/docker-compose.yml # ACTUAL compose file
/docker/deploy-vps/.env # EMPTY (no secrets β might be why rest didn't start)
/docker/deploy-vps/ # docker compose -f docker-compose.yml up -d rest
Kong config (declarative, Kong uses DATABASE=off)
Kong container: /tmp/kong.yml
Backup: /var/www/documentos/deploy-vps/supabase-selfhost/volumes/api/kong.yml
Project path (frontend Next.js)
/opt/rochasales
`
Common Silent Failure: Container Defined But Not Running
Kong container may be on a different Docker network than the other services (db, auth, storage). This prevents Kong from reaching backends.
Fix: Ensure Kong is on deploy-vps_default network alongside db, auth, storage containers.
Database (PostgreSQL)
`bash
Connect to PostgreSQL
docker exec deploy-vps-db-1 psql -U postgres -d postgres
Key tables:
public.profiles β has custom_role_id FK to custom_roles
public.user_roles β EMPTY (this is what has_role() checks)
public.broker_links β 7 tools
public.tool_role_access β 18 rules
public.custom_roles β 4 roles: Corretor, ADM, Gestor, PrΓ©-Venda
auth.profiles β EMPTY, separate from public.profiles
Important: has_role() function checks public.user_roles, NOT auth.profiles
has_role(user_id, 'admin') β SELECT role FROM public.user_roles WHERE user_id = ? AND role::text = ?
`
Database Fix Applied (2026-05-21)
`sql
-- Admin user custom_role_id changed from Gestor to ADM
UPDATE public.profiles
SET custom_role_id = '9bc6f80c-8e01-4ec0-9f24-a7a3a4c482dd'
WHERE user_id = '9b645fa9-c5ed-4537-a803-4b66d6e6b63d';
`
Two Separate Supabase Projects
DO NOT confuse these two β they are completely different projects with different databases.