The Prefect CLI is the easiest way to start a local instance of Prefect server.
Start the server
- Spin up a self-hosted Prefect server instance UI with the
prefect server start CLI command in the terminal:
- Open the URL for the Prefect server UI (http://127.0.0.1:4200 by default) in a browser.
- Shut down the Prefect server with ctrl + c in the terminal.
Go to your terminal session and run this command to set the API URL to point to a self-hosted Prefect server instance:
You can save the API server address in a Prefect profile.
Whenever that profile is active, the API endpoint is at that address.
See Profiles and configuration for more information on profiles and configurable Prefect settings.
Database configuration
Use SQLite (default)
By default, Prefect uses a SQLite database stored at ~/.prefect/prefect.db. No additional configuration is needed for basic use.
Use PostgreSQL
To use PostgreSQL as your database backend:
- Set the database connection URL:
- Start the server:
For more database configuration options, see the database settings reference.
Database management commands
Reset the database
Clear all data and reapply the schema:
Manage migrations
Apply database migrations:
For large databases, you may need to increase the timeout:
Multi-worker API server
For high-throughput scenarios, you can run the server with multiple worker processes to handle concurrent requests more efficiently:
This starts 4 worker processes to handle API and UI requests concurrently.
Requirements for multi-worker mode
Multi-worker mode has specific infrastructure requirements:
- PostgreSQL database — SQLite is not supported due to database locking issues
- Redis for messaging, event ordering, and concurrency lease storage — the in-memory defaults do not work across processes
prefect server start --workers validates these requirements at startup. If any required
Redis-backed setting is still using its in-memory default, the server exits with an error
before starting. See the configuration example below for the full set of required settings.
Configuration example
For a complete Redis setup including authentication, TLS, and Docket coordination for
background services, see How to scale self-hosted Prefect.
The number of workers should typically match the number of CPU cores available to your server process, but you may need to experiment to find the optimal value for your workload.
Advanced configuration
For advanced deployment scenarios including:
- Running behind a reverse proxy
- Configuring SSL certificates
- Multi-server deployments
- Handling migration issues
See How to scale self-hosted Prefect.