In short: run PocketBase as a systemd service bound to 127.0.0.1:8090, put Caddy in front of it for automatic HTTPS, then enable SMTP, a settings encryption key and backups. Plan about 20 minutes on a fresh Ubuntu server.
PocketBase ships as a single executable with an embedded SQLite database, which makes it easy to start and just as easy to deploy badly. Running ./pocketbase serve in an SSH session works until the terminal closes. This guide builds a setup you can leave running: a dedicated user, a service that restarts itself, HTTPS, and the settings the official documentation recommends before going live.
If you prefer containers, read our guide to installing PocketBase with Docker Compose. To see what the API gives you once it is online, see PocketBase: the easy way to create your secure REST API.
Prerequisites
- A Linux VPS (this guide uses Ubuntu 22.04 or 24.04) and a user with
sudo - A domain or subdomain such as
pb.example.com, with anArecord pointing to the server - Ports 80 and 443 reachable from the internet
- PocketBase v0.23 or later. Older versions use “admins” and an “Admin UI”; newer ones use superusers and the Dashboard
- Caddy installed (see the official install instructions)
How the pieces fit together
Visitors connect to Caddy on ports 80 and 443. Caddy handles the TLS certificate and forwards requests to PocketBase, which listens only on 127.0.0.1:8090. Your data lives in the pb_data folder next to the executable. Because PocketBase is not exposed directly, the firewall can stay closed on port 8090.
Step 1: create a dedicated user and folder
bashsudo useradd --system --home /opt/pocketbase --shell /usr/sbin/nologin pocketbase
sudo mkdir -p /opt/pocketbase
Running the service as its own unprivileged user limits the damage if the app is ever compromised.
Step 2: download PocketBase
Open the PocketBase releases page, copy the latest version number and use it below. On ARM servers, replace amd64 with arm64.
bashPB_VERSION=X.Y.Z # replace with the latest version
cd /tmp
curl -fLO "https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip"
unzip pocketbase_${PB_VERSION}_linux_amd64.zip pocketbase
sudo mv pocketbase /opt/pocketbase/
sudo chown -R pocketbase:pocketbase /opt/pocketbase
Step 3: create a superuser
bashsudo -u pocketbase /opt/pocketbase/pocketbase superuser create [email protected] 'a-long-unique-password'
This account gives full access to the Dashboard, so use a password manager and a strong passphrase.
Step 4: store the settings encryption key
PocketBase can encrypt the application settings (SMTP password, S3 secrets, OAuth2 secrets) stored in the database. Set the key before you configure anything, and keep a copy in your password manager: without it, the encrypted settings cannot be read.
bashecho "PB_ENCRYPTION_KEY=$(openssl rand -hex 16)" | sudo tee /etc/pocketbase.env
sudo chmod 600 /etc/pocketbase.env
Step 5: run PocketBase with systemd
Create /etc/systemd/system/pocketbase.service:
ini[Unit]
Description=PocketBase
After=network.target
[Service]
Type=simple
User=pocketbase
Group=pocketbase
WorkingDirectory=/opt/pocketbase
EnvironmentFile=/etc/pocketbase.env
ExecStart=/opt/pocketbase/pocketbase serve --http=127.0.0.1:8090 --encryptionEnv=PB_ENCRYPTION_KEY
LimitNOFILE=4096
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Enable and start it, then read the logs:
bashsudo systemctl daemon-reload
sudo systemctl enable --now pocketbase
sudo systemctl status pocketbase
journalctl -u pocketbase -f
Step 6: add HTTPS with Caddy
Edit /etc/caddy/Caddyfile:
textpb.example.com {
request_body {
max_size 10MB
}
reverse_proxy 127.0.0.1:8090 {
transport http {
read_timeout 360s
}
}
}
The max_size value caps uploads, so raise it if your app accepts large files. The long read_timeout keeps realtime (SSE) connections alive. Reload Caddy and it obtains and renews the certificate on its own:
bashsudo systemctl reload caddy
Step 7: open only the ports you need
bashsudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable
Step 8: finish the setup in the Dashboard
Open https://pb.example.com/_/ and sign in. Then go through Settings:
- Set the Application URL to your public address.
- Configure an SMTP server. The default mail method is unreliable in production and your emails are likely to land in spam.
- Review the built-in rate limiter and tighten it for your login and API routes.
- Set up backups. We cover this in detail in PocketBase backup and restore.
Update PocketBase safely
PocketBase is still below v1.0, so breaking changes can happen between releases. Read the release notes first, take a backup, then update:
bashsudo -u pocketbase /opt/pocketbase/pocketbase update
sudo systemctl restart pocketbase
Troubleshooting
- 502 Bad Gateway from Caddy: the service is not running or listens on another port. Check
systemctl status pocketbase. - Certificate not issued: the DNS record does not point to the server yet, or ports 80 and 443 are blocked.
- Realtime connections drop: keep the
read_timeoutsetting in the Caddyfile. - Uploads fail: increase
max_sizein the Caddyfile and check the file limits on the collection field. - Permission denied on
pb_data: runsudo chown -R pocketbase:pocketbase /opt/pocketbase.
FAQ
Do I need Caddy to use HTTPS with PocketBase?
No. PocketBase can obtain a Let’s Encrypt certificate itself when you start it with your domain, for example pocketbase serve yourdomain.com. A reverse proxy such as Caddy is more flexible when you host several apps on one server or want finer control over limits and headers.
Is SQLite good enough for production?
For many small and medium applications, yes. PocketBase runs on a single node, so plan for backups and for the limits of one server. Test your expected load before launch.
Where is my data stored?
In the pb_data folder: the SQLite database, uploaded files and logs. Back it up regularly and test a restore.
Next steps
Your server is now online. Protect it with backups you have actually restored, then connect your front end with PocketBase authentication in JavaScript. For the full list of recommendations, read the official going to production guide.