Deploy Pocketbase

Backend in 1 file: auth, database, file storage, realtime and backups.

Deploy Pocketbase

Just deployed

/pb/pb_data

Deploy and Host PocketBase on Railway

PocketBase is an open source backend packed into a single Go binary. It bundles an embedded SQLite database with realtime subscriptions, user authentication with OAuth2, file storage, an auto-generated REST API, and an admin dashboard. One process replaces the database, auth provider, file bucket, and API server you would otherwise wire together yourself.

About Hosting PocketBase

Hosting PocketBase means running one container with a persistent volume attached. The SQLite database, uploaded files, and instance settings all live in a single directory, so the hosting problem reduces to keeping that directory intact across restarts and redeploys. This template mounts a Railway volume at /pb/pb_data and points PocketBase at it explicitly — the step most self-hosted deployments skip, and the reason people lose their data on the second push. Railway builds the image from the included Dockerfile, assigns a public HTTPS domain, restarts the container if it crashes, and exposes vertical scaling as a slider. There is no reverse proxy to configure and no TLS certificate to renew.

Common Use Cases

  • Mobile and web app backends — pair with the official JavaScript or Dart/Flutter SDK for realtime data sync, user authentication, and file uploads without writing server code.
  • MVPs and prototypes — stand up auth, a database, and file storage in minutes to validate an idea before committing to a larger stack.
  • Internal tools and admin panels — use the built-in dashboard to manage records directly, instead of building a custom CRUD interface.
  • Small production SaaS — a low-maintenance backend for products that don't yet justify separate database, cache, and API services.
  • Learning and experimentation — a disposable environment for trying PocketBase hooks, collection rules, and auth flows.

Dependencies for PocketBase Hosting

  • A Railway persistent volume — pre-configured by this template and mounted at /pb/pb_data. Without it, all data is lost on every redeploy.
  • Docker — the image is built from the included Dockerfile. Nothing to install yourself.
  • An SMTP provider (optional) — PocketBase has no mail server built in. Email verification and password resets require SMTP credentials from a provider such as Resend, Postmark, or Amazon SES, configured in the admin dashboard.
  • S3-compatible storage (optional) — for off-volume backups or file storage. AWS S3, Cloudflare R2, Backblaze B2, or a self-hosted MinIO all work.

Implementation Details

Getting started after deploy

  1. Open your service URL with /_/ appended — for example https://your-app.up.railway.app/_/.
  2. Create your first superuser on the setup screen.
  3. Create a collection. Its REST endpoints exist immediately.

If no public URL appears, open the service's Settings → Networking and click Generate Domain.

Configuration

Every variable is optional; the template runs with none of them set.

VariableDefaultDescription
PORT8080Injected by Railway and used automatically.
PB_VERSION0.40.4Build argument. Set it to build a different PocketBase release without editing the Dockerfile.
TZUTCTimezone for the backup cron schedule and log timestamps, e.g. America/Bogota.
PB_ENCRYPTION_KEYunsetA 32-character key. When present, PocketBase encrypts stored settings at rest.

SMTP, OAuth providers, backup schedules, and S3 storage are configured through the admin dashboard rather than environment variables.

Your SMTP password and OAuth client secrets are stored in the database in plain text unless PB_ENCRYPTION_KEY is set. Keep that key somewhere safe — losing it makes the encrypted settings unrecoverable.

The health check path is /api/health, so Railway won't route traffic to a container that failed to start.

Where your data lives

/pb/pb_data/
├── data.db          # collections, records, users
├── auxiliary.db     # logs
└── storage/         # uploaded files

Three extension directories sit alongside it: /pb/pb_hooks for JavaScript hooks, /pb/pb_migrations for schema migrations, and /pb/pb_public for static files served at the root of your domain.

Backups

A volume is not a backup. PocketBase includes its own backup system under Settings → Backups in the admin dashboard, where you can create backups on demand, set a cron schedule (0 3 * * * for a daily 3am run), choose how many to retain, and restore any of them.

Backups are written to the same volume by default, which protects against a bad migration but not against losing the volume. For real durability, enable S3 storage for backups in the same settings screen.

Connecting your app

import PocketBase from 'pocketbase';

const pb = new PocketBase('https://your-app.up.railway.app');

await pb.collection('users').authWithPassword('user@example.com', 'password');

const posts = await pb.collection('posts').getList(1, 20, {
  filter: 'published = true',
  sort: '-created',
});

pb.collection('posts').subscribe('*', (e) => {
  console.log(e.action, e.record);
});

Official SDKs: JavaScript/TypeScript for browser, Node.js and React Native, and Dart/Flutter for web, mobile and desktop.

Upgrading

PocketBase is pre-v1.0.0 and ships releases often, so this template pins a version rather than tracking latest. To upgrade: read the changelog, take a backup, set PB_VERSION to the new release number without the leading v, and redeploy. Railway rebuilds against the same volume. Rolling back is the same operation in reverse, plus restoring the backup if the newer version already migrated your database.

Troubleshooting

  • The dashboard returns 404. The admin UI lives at /_/, not at the root.
  • Lost superuser password. Open the service shell and run /pb/pocketbase superuser update your@email.com newpassword.
  • Files disappeared after a redeploy. Confirm the volume is still mounted at /pb/pb_data. If the mount path changed, PocketBase wrote to the container's ephemeral filesystem.
  • Emails aren't sending. Configure SMTP under Settings → Mail settings. Without it, verification and password reset emails fail silently.
  • Backups run at the wrong hour. Set the TZ variable — the cron schedule follows the container timezone, which is UTC by default.

Why Deploy PocketBase on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PocketBase on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


PocketBase is still under active development and has not reached v1.0.0, so full backward compatibility between minor versions is not guaranteed. Skim the changelog before upgrading anything critical.

Licensed under the MIT License.

Having trouble with this template? Ask in the template queue — questions get answered.


Template Content

More templates in this category

View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8
View Template
Redis
Self Host Latest Redis with Railway

8
View Template
NEW
Plik File Sharing
Expiring file sharing with authenticated uploads and persistent metadata.

orenaksakal
0