
Deploy PocketBase
Open Source Go Backend that Includes Embedded Database (SQLite)
PocketBase
Just deployed
/pb/pb_data
PocketBase on Railway
Deploy PocketBase on Railway with a simple Dockerfile.
What is PocketBase?
PocketBase is an open-source backend consisting of:
- Embedded database (SQLite) with realtime subscriptions
- Built-in auth management with email/password and OAuth2
- Convenient Admin dashboard UI
- Simple REST-ish API
- File storage (local or S3)
Deploy and Host
About Hosting
Hosting PocketBase on Railway provides a cloud-based solution for running your backend without managing servers. Railway offers automatic deployments, built-in HTTPS, persistent storage through volumes, and a generous free tier perfect for development and small production workloads. The platform handles infrastructure concerns while you focus on building your application.
Why Deploy
Deploying PocketBase to Railway gives you several advantages over local development or traditional hosting:
- Instant Accessibility: Your backend is immediately available via HTTPS with a public URL
- Zero Server Management: No need to configure servers, SSL certificates, or worry about infrastructure
- Automatic Scaling: Railway handles traffic spikes without manual intervention
- Persistent Storage: Built-in volume support ensures your data survives redeployments
- Cost Effective: Free tier for small projects, pay-as-you-grow pricing
- CI/CD Integration: Automatic deployments from GitHub on every push
- Development to Production: Seamless progression from prototype to production-ready backend
Common Use Cases
PocketBase on Railway is ideal for:
- Mobile App Backends: Provide authentication, database, and file storage for iOS/Android apps
- SaaS MVPs: Rapidly prototype and launch software-as-a-service products
- Internal Tools: Build admin dashboards and internal applications for your team
- Client Projects: Deliver complete backend solutions for web development clients
- Personal Projects: Host hobby projects and side businesses without infrastructure overhead
- Prototypes & Demos: Quickly spin up functional backends for proof-of-concepts
- JAMstack Applications: Power static sites with dynamic data and user authentication
- IoT Data Collection: Store and manage data from IoT devices and sensors
Dependencies for
Deployment Dependencies
This deployment requires:
- Railway Account: Free account at railway.app
- GitHub Account: For repository connection and automatic deployments
- Docker: Railway uses the provided Dockerfile (no local Docker installation needed)
- Git Repository: This repository cloned or forked to your GitHub account
Runtime Dependencies (automatically handled):
- PocketBase binary (downloaded during build based on
PB_VERSION) - SQLite (embedded in PocketBase)
- Linux environment (provided by Railway container)
Optional Dependencies:
- Custom domain (can use Railway's generated domain)
- S3-compatible storage (for external file storage instead of local)
Deployment Steps
1. Create a New Project on Railway
- Go to Railway.app
- Click "New Project"
- Select "Deploy from GitHub repo"
- Connect and select this repository
2. Configure Service Settings
After deployment, configure these settings in Railway UI:
Service Settings:
- Build Method: Dockerfile
- Dockerfile Path:
Dockerfile(default)
Service Variables:
- Add variable:
PORT(Railway provides this automatically, but ensure it's available) - Optional:
PB_VERSION=0.23.6(or your preferred version)
Deploy Settings:
- Start Command: (Leave empty, Dockerfile CMD will be used)
- Restart Policy: On Failure
- Health Check: (Optional) Path:
/_/
3. Add Volume for Data Persistence
Critical Step - Without this, your data will be lost on redeployment!
- Go to your service in Railway
- Click on "Settings" tab
- Scroll to "Volumes"
- Click "Add Volume"
- Set mount path:
/pb/pb_data - Click "Add"
4. Generate Domain
- In your service, go to "Settings"
- Find "Networking" section
- Click "Generate Domain"
- Your PocketBase will be available at the generated URL
Accessing Your PocketBase
After deployment completes:
First-Time Setup (Creating Admin Account)
Important: On first deployment, PocketBase generates a special installation URL with a token. You need to use this URL to create your admin account.
- Go to your Railway service "Deployments" tab
- Click on the latest deployment to view logs
- Look for a line that says:
Launch the URL below in the browser... - Copy the installation URL that looks like:
http://0.0.0.0:8080/_/#/pbinstal/eyJhbGci...LONG_TOKEN_HERE - Replace
http://0.0.0.0:8080with your Railway domain:https://your-project.railway.app/_/#/pbinstal/eyJhbGci...LONG_TOKEN_HERE - Visit this URL to create your admin account
Alternative method if the token expires:
- Go to your service in Railway
- Open the Terminal/Shell
- Run:
/pb/pocketbase superuser upsert [email protected] yourpassword
Admin Dashboard
After creating your account, access the admin UI at:
https://your-project.railway.app/_/
API Endpoint
Your API is available at:
https://your-project.railway.app/api/
Manual Configuration in Railway UI
If deploying without the Deploy button, here's the complete manual setup:
- Create New Project → Empty Project
- Add Service → GitHub Repo
- Service Settings:
- Builder: Dockerfile
- Add Volume:
- Mount Path:
/pb/pb_data
- Mount Path:
- Generate Domain
- Deploy
Environment Variables (Optional)
You can customize these in Railway's Variables tab:
| Variable | Default | Description |
|---|---|---|
PB_VERSION | 0.23.6 | PocketBase version to install |
PORT | Auto-set by Railway | Port to run PocketBase on |
Updating PocketBase Version
To update to a newer version:
- Change the
PB_VERSIONvariable in Railway - Redeploy the service
- Your data will persist in the volume
Features
- ✅ Simple Dockerfile deployment
- ✅ Persistent storage with Railway volumes
- ✅ Automatic HTTPS
- ✅ Admin UI included
- ✅ Ready for production use
- ✅ Easy version updates
Repository Structure
.
├── Dockerfile # Container configuration
└── README.md # This file
Troubleshooting
Service won't start
- Check that the volume is mounted at
/pb/pb_data - Verify PORT variable is available
- Check Railway logs for errors
Data lost after redeploy
- Ensure volume is properly configured and mounted
- Volume must be at
/pb/pb_data
Can't access admin dashboard
- Navigate to
/_/(with trailing slash) - Create admin account if first time
Documentation
Support
For issues related to:
- PocketBase: Visit PocketBase GitHub Issues
- Railway Deployment: Visit Railway Discord
License
PocketBase is licensed under the MIT License.
Template Content
PocketBase
AnarchistManifesto/PocketBase