Skip to main content
PocketBase provides a powerful command-line interface for managing your backend. This page documents all available commands and their flags.

Global Flags

These flags are available for all commands and should be specified before the command name.
string
default:"./pb_data"
The PocketBase data directory where your database, migrations, and settings are stored.
string
The environment variable name whose value (32 characters) will be used as the encryption key for app settings.
boolean
default:"false"
Enable development mode, which prints logs and SQL statements to the console for debugging.
integer
default:"30"
The default timeout for SELECT queries in seconds.

serve

Starts the PocketBase web server with optional automatic HTTPS via Let’s Encrypt.

Usage

Flags

string
default:"127.0.0.1:8090"
TCP address to listen for HTTP requests.
  • Default (no domains): 127.0.0.1:8090
  • Default (with domains): 0.0.0.0:80
string
TCP address to listen for HTTPS requests with automatic TLS certificate management via Let’s Encrypt.
  • Default (no domains): empty (no TLS)
  • Default (with domains): 0.0.0.0:443
When enabled, HTTP traffic is automatically redirected to HTTPS.
string[]
default:"[\"*\"]"
CORS allowed domain origins list. Use this to restrict which domains can access your PocketBase API.

Domain Parameters

When you provide domain names as arguments, PocketBase automatically:
  • Obtains and manages Let’s Encrypt TLS certificates
  • Sets default HTTP address to 0.0.0.0:80
  • Sets default HTTPS address to 0.0.0.0:443
  • Redirects HTTP traffic to HTTPS
For automatic HTTPS to work, your domain(s) must point to your server’s public IP address and ports 80 and 443 must be accessible.

superuser

Manage superuser accounts for administrative access to your PocketBase instance.

superuser create

Creates a new superuser account.

superuser update

Changes the password of an existing superuser.
The superuser must already exist. Use superuser create for new accounts or superuser upsert to create or update.

superuser upsert

Creates a new superuser or updates the password if the email already exists.
This is the recommended command when you want to ensure a superuser exists with a specific password, regardless of whether the account already exists.

superuser delete

Deletes an existing superuser account.

superuser otp

Creates a new one-time password (OTP) for the specified superuser account.
Output example:
OTP authentication must be enabled for the _superusers collection for this command to work. The OTP length and validity duration are configured in the collection settings.

migrate

Executes database migration scripts. This command is available when the migratecmd plugin is registered.

Usage

Commands

Runs all available migrations that haven’t been applied yet.
Reverts the last [number] applied migrations.
Creates a new blank migration template file with the specified name.
Creates a new migration file with a snapshot of the current collections configuration.
This is useful for version controlling your schema changes.
Ensures that the _migrations history table doesn’t have references to deleted migration files.

Examples

Migration files are created in the migrations/ directory by default (Go templates) or pb_migrations/ (JavaScript templates). The directory can be customized via plugin configuration.

update

Automatically updates the current PocketBase executable with the latest available version from GitHub releases. This command is available when the ghupdate plugin is registered.

Flags

boolean
default:"true"
Creates a backup of the pb_data directory at the end of the update process.

Process

When you run the update command, PocketBase will:
  1. Fetch the latest release information from GitHub
  2. Compare versions and skip if already up to date
  3. Download the appropriate release for your platform
  4. Extract the new executable
  5. Replace the current executable
  6. Create a backup (if --backup=true)
  7. Display release notes

Example Output

The update command may not work as expected in Docker containers or NixOS environments. PocketBase will warn you if it detects these environments and ask for confirmation before proceeding.

version

Displays the current PocketBase version.

help

Displays help information for PocketBase commands.

Example Workflows

Development Setup

Production Deployment

Initial Setup

Migration Workflow

Backup Before Update