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:supabase folder with the following structure:
Start Local Services
Launch all Supabase services:Access Your Services
Once started, you’ll see output with URLs and credentials: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

PostgreSQL Database
Connection String:postgresql://postgres:postgres@localhost:54322/postgres
Connect to your local Postgres instance using any client:
- psql
- pgAdmin
- Edge Functions
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

Configuration
Customize your local environment by editingsupabase/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 startManaging Local Services
Check Status
View the status of all running services:Stop Services
Stop all services without deleting data:Stop and Reset
Stop services and delete all data:Restart Services
Restart all services:Working with Your Application
Client Libraries
Configure your Supabase client to use local services:- JavaScript
- Python
- Dart/Flutter
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
Editsupabase/seed.sql:
seed.sql
Apply Seed Data
Reset your database to apply migrations and seed data:- Drop the database
- Reapply all migrations
- Run the seed.sql file
Testing and Linting
Test Your Database
Run database tests using pgTAP:supabase/tests/:
tests/todos_test.sql
Lint Your Database
Check for common issues:- 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 yourconfig.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
Services won't start
Services won't start
Error:
Port already in useSolution:- Check for conflicting services:
lsof -i :54321 - Stop other Supabase instances:
supabase stop - Change ports in
config.toml
Database connection failed
Database connection failed
Error:
could not connect to serverSolution:- Ensure Docker is running:
docker ps - Check services status:
supabase status - Restart services:
supabase stop && supabase start
Studio not loading
Studio not loading
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:54323instead oflocalhost
Migration errors
Migration errors
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
