Skip to main content
The Supabase CLI enables you to run the entire Supabase stack locally, giving you a complete development environment that mirrors production.

Why Develop Locally?

Developing locally with the Supabase CLI provides several advantages:
  • Faster development: Make changes instantly without network latency
  • Offline development: Work without internet connectivity
  • Cost effective: No charges for development API calls
  • Isolated testing: Test breaking changes safely
  • Version control: Track database schema in Git
  • Team collaboration: Share migrations across your team

Getting Started

Initialize a Project

Create a new Supabase project in your current directory:
This creates a supabase folder with the following structure:
It’s safe to commit the entire supabase folder to version control.

Start Local Services

Launch all Supabase services:
The first run takes several minutes as Docker downloads all required images (approximately 2-3 GB).

Access Your Services

Once started, you’ll see output with URLs and credentials:
These credentials are for local development only. Never use them in production.

Available Services

Studio (Database Management)

URL: http://localhost:54323 Supabase Studio provides a web interface for managing your database:
  • Visual table editor
  • SQL editor with autocomplete
  • Query history
  • Database relationships viewer
  • RLS policy builder
  • Real-time data viewer
Supabase Studio running locally

PostgreSQL Database

Connection String: postgresql://postgres:postgres@localhost:54322/postgres Connect to your local Postgres instance using any client:

API Gateway

Base URL: http://localhost:54321 Kong serves as the API gateway, routing requests to different services:
  • REST API: http://localhost:54321/rest/v1/
  • Realtime: http://localhost:54321/realtime/v1/
  • Storage: http://localhost:54321/storage/v1/
  • Auth: http://localhost:54321/auth/v1/

Using the API

When accessing services without client libraries, pass the anon key as an Authorization header:
The anon key is displayed when you run supabase start.

Mailpit (Email Testing)

URL: http://localhost:54324 Mailpit captures all emails sent by Supabase Auth, allowing you to test:
  • Email verification flows
  • Password reset emails
  • Magic link authentication
  • Email change confirmations
Mailpit email testing interface

Configuration

Customize your local environment by editing supabase/config.toml:

Change Ports

config.toml

Configure Auth Providers

config.toml

Set JWT Secrets

config.toml
Changes to config.toml require restarting local services: supabase stop && supabase start

Managing Local Services

Check Status

View the status of all running services:
Output:

Stop Services

Stop all services without deleting data:
This preserves your database state between sessions.

Stop and Reset

Stop services and delete all data:
This permanently deletes all local data. Use with caution.

Restart Services

Restart all services:

Working with Your Application

Client Libraries

Configure your Supabase client to use local services:

Environment Variables

Use environment variables to switch between local and production:
.env.local
.env.production

Seeding Data

Create seed data for consistent development:

Create Seed File

Edit supabase/seed.sql:
seed.sql

Apply Seed Data

Reset your database to apply migrations and seed data:
This will:
  1. Drop the database
  2. Reapply all migrations
  3. Run the seed.sql file

Testing and Linting

Test Your Database

Run database tests using pgTAP:
Create test files in supabase/tests/:
tests/todos_test.sql

Lint Your Database

Check for common issues:
This validates:
  • Correct types for function parameters
  • Unused variables
  • Dead code after RETURN statements
  • Missing RETURN statements
  • SQL injection vulnerabilities

Logs and Analytics

View Logs

Local logs are stored in the _analytics schema and accessible via Studio.

Configure Logging

For advanced log analysis, configure the BigQuery backend in your config.toml:
config.toml
On macOS/Linux, logs are accessed via /var/run/docker.sock. On Windows, ensure tcp://localhost:2375 is exposed in Docker settings.

Troubleshooting

Error: Port already in useSolution:
  • Check for conflicting services: lsof -i :54321
  • Stop other Supabase instances: supabase stop
  • Change ports in config.toml
Error: could not connect to serverSolution:
  • Ensure Docker is running: docker ps
  • Check services status: supabase status
  • Restart services: supabase stop && supabase start
Error: Studio page shows connection errorSolution:
  • Verify services are running: supabase status
  • Check browser console for errors
  • Clear browser cache and reload
  • Try accessing http://127.0.0.1:54323 instead of localhost
Error: migration failed to applySolution:
  • Check migration SQL syntax
  • Review error message for specifics
  • Test migration individually: supabase db reset
  • Roll back and fix: supabase db diff -f fix_migration

Next Steps

Database Migrations

Learn to manage schema changes with migrations

Testing Guide

Set up comprehensive database testing

Deploy to Production

Push your local project to Supabase Platform

CLI Reference

Explore all available CLI commands