Why self-host PocketBase on a VPS
PocketBase is an open source backend-as-a-service distributed as a single binary: no separate Postgres, no Redis, no complex stack to orchestrate. Everything relies on SQLite, which makes it perfectly suited to an entry-level VPS. By self-hosting it, you keep full control of your user data and your files, without depending on a managed Firebase or Supabase whose quotas and latency from Morocco can be problematic. A VPS gives you a fixed IP, a custom domain, and backups you control. Since PocketBase writes to a single pb_data folder, the backup strategy comes down to copying that directory, which enormously simplifies operations compared to a classic database cluster.
The concrete benefits of self-hosting PocketBase
- A single binary to deploy: startup in seconds, minimal memory footprint (often less than 100 MB of RAM).
- Embedded SQLite database: zero database service to administer, backup by simply copying the
pb_datafolder. - Authentication, access rules, file management, and a real-time API via WebSocket included out of the box.
- A complete web admin interface to manage collections, users, and permissions without writing SQL.
- Data sovereignty: your users and their files stay on your infrastructure, behind your domain.
- Predictable cost: a modest VPS is enough for tens of thousands of requests per day.
Hardware and software prerequisites
PocketBase is extremely frugal. A VPS with 1 vCPU and 1 GB of RAM handles a modest-to-medium-sized production project without difficulty; 2 GB give a comfortable margin for the SQLite cache and real-time traffic spikes. On the storage side, plan for 20 to 40 GB of SSD depending on the volume of files uploaded by your users. You'll need Docker and Docker Compose (or simply the binary and systemd), a domain or subdomain pointing to the VPS IP via an A record, and a reverse proxy (Caddy, Nginx, or Traefik) to handle TLS. Since SQLite is single-file, favor an NVMe SSD disk for good concurrent write performance.
Deploying PocketBase step by step
Prepare the VPS and DNS
Connect via SSH, update the system with apt update && apt upgrade -y, then install Docker via curl -fsSL https://get.docker.com | sh. Create an A-type DNS record pointing app.mydomain.com to your VPS's public IP and wait for propagation.
Write the docker-compose.yml
Use a PocketBase image (e.g., ghcr.io/muchobien/pocketbase), expose port 8090 internally, and mount a named volume on /pb_data to persist the database and files: volumes: - ./pb_data:/pb_data. Do NOT publish the port directly on the Internet; let the reverse proxy handle it.
Launch the container
Run docker compose up -d then docker compose logs -f to verify that PocketBase starts and displays the admin URL. The service listens internally on 0.0.0.0:8090.
Configure the reverse proxy and SSL
With Caddy, a three-line Caddyfile is enough: app.mydomain.com { reverse_proxy localhost:8090 }. Caddy automatically obtains and renews the Let's Encrypt certificate. Remember to allow WebSocket pass-through for real-time subscriptions (Caddy does this by default; under Nginx, add the Upgrade and Connection headers).
Create the admin account and the collections
Open https://app.mydomain.com/_/, create the first super-admin account, then define your collections, your API rules (@request.auth.id != ""), and your OAuth authentication providers if needed.
Automate backups
Schedule a cron that archives the pb_data folder (tar czf backup-$(date +%F).tar.gz pb_data) to external storage. PocketBase also offers built-in backups that can be triggered from the admin or the API.
Enable SQLite's WAL mode (PocketBase does this by default in recent versions) to allow concurrent reads during writes: it's the number one performance lever. For high traffic, place the pb_data folder on an NVMe volume and avoid NFS or any network file system, which greatly degrades SQLite's performance and can corrupt the database in case of poorly managed locks.
The official documentation
For advanced configuration and tool-specific options, refer to the official PocketBase documentation. This guide covers going live on a VPS; the vendor's documentation remains the reference for fine-tuning, major upgrades, and specific use cases.