Skip to main content
PocketBase is a single executable file that you can deploy anywhere. This flexibility makes it suitable for various hosting environments, from traditional VPS servers to modern cloud platforms.

Deployment options

You can deploy PocketBase using several approaches:
  • Standalone binary: Download and run the PocketBase executable directly on your server
  • Docker container: Use containerization for consistent deployment across environments
  • Platform-as-a-Service: Deploy to platforms like Fly.io, Railway, or DigitalOcean App Platform
  • Traditional VPS: Run on virtual private servers from providers like AWS, Google Cloud, or DigitalOcean

System requirements

PocketBase has minimal system requirements:
  • Operating system: Linux, macOS, or Windows (restore functionality requires Unix-based systems)
  • Memory: As little as 256MB RAM for small applications
  • Storage: Depends on your data volume and backup strategy
  • Architecture: Supports amd64, arm64, and armv7
For production deployments, you should have at least 2x the size of your pb_data directory available as free disk space to safely perform backups.

Data directory structure

PocketBase stores all data in the pb_data directory:
pb_data/
├── data.db              # Main SQLite database
├── data.db-shm          # Shared memory file (temporary)
├── data.db-wal          # Write-ahead log (temporary)
├── backups/             # Local backup files
├── storage/             # Uploaded files
└── logs.db              # Application logs
Always back up the entire pb_data directory, not just the database files. The directory contains uploaded files and other critical data.

Running PocketBase

Start PocketBase with the serve command:
./pocketbase serve
Common flags:
  • --http: Change the HTTP server address (default: 127.0.0.1:8090)
  • --dir: Specify a custom data directory (default: ./pb_data)
  • --publicDir: Set a custom public directory path
  • --hooksDir: Set a custom hooks directory path
  • --migrationsDir: Set a custom migrations directory path
Example with custom configuration:
./pocketbase serve --http="0.0.0.0:80" --dir="/var/lib/pocketbase/data"
Binding to 0.0.0.0 makes PocketBase accessible from external networks. Use 127.0.0.1 for local-only access.

Environment variables

PocketBase supports configuration through environment variables:
  • Encryption: Set the encryption key for sensitive settings
    export PB_ENCRYPTION_KEY="your-32-char-encryption-key"
    
  • Data directory: Override the default data directory
    export PB_DATA_DIR="/custom/path/to/data"
    

Process management

For production deployments, use a process manager to ensure PocketBase runs continuously:

systemd (Linux)

Create a systemd service file at /etc/systemd/system/pocketbase.service:
[Unit]
Description=PocketBase
After=network.target

[Service]
Type=simple
User=pocketbase
Group=pocketbase
WorkingDirectory=/opt/pocketbase
ExecStart=/opt/pocketbase/pocketbase serve --http="0.0.0.0:8090"
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl enable pocketbase
sudo systemctl start pocketbase

Docker

Create a Dockerfile:
FROM alpine:latest

RUN apk add --no-cache ca-certificates

COPY pocketbase /usr/local/bin/pocketbase

EXPOSE 8090

CMD ["/usr/local/bin/pocketbase", "serve", "--http=0.0.0.0:8090"]
Run with Docker:
docker run -d \
  -p 8090:8090 \
  -v /path/to/pb_data:/pb_data \
  pocketbase:latest

Reverse proxy

In production, you should run PocketBase behind a reverse proxy like nginx or Caddy for:
  • SSL/TLS termination
  • Load balancing
  • Rate limiting
  • Static file serving

nginx example

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:8090;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Caddy example

example.com {
    reverse_proxy localhost:8090
}

Next steps

Going to production

Learn about production-specific configurations and best practices

Backups

Set up automated backups to protect your data

Migrations

Manage database schema changes with migrations