PocketBase on Ubuntu
This guide provides detailed instructions to set up PocketBase on your Oracle Cloud Ubuntu instance, including configuring email for user registration and addressing the need for a domain name. It assumes you have an Oracle Cloud Ubuntu instance ready and excludes Flutter-related changes, as requested.
Prerequisites
- Oracle Cloud Ubuntu instance (e.g., Ubuntu 22.04) with a public IP address.
- (Optional but recommended) A domain name with DNS configured to point to your instance’s public IP. (you can work with IP also)
- SSH access to your instance.
- A third-party SMTP service account (e.g., MailerSend, Brevo, SendGrid, Mailgun, AWS SES or Good Old GMAIL) for email functionality.
Step 1: Download PocketBase
- Get link for here - https://github.com/pocketbase/pocketbase/releases
wget https://github.com/pocketbase/pocketbase/releases/download/v0.29.1/pocketbase_0.29.1_linux_amd64.zip
Step 2: Create Work Directory
- Create working drectory and unzip the content
mkdir pb
cd pb
unzip pocketbase_0.29.1_linux_amd64.zip
Step 3: Make Executable
- Make the
pocketbase
executable runnable:chmod +x pocketbase
Step 4: Configure Oracle Cloud Security Lists
- Ensure your instance allows incoming traffic on ports 80 (HTTP) and 443 (HTTPS).
- In the Oracle Cloud Console:
- Go to Compute > Instances.
- Select your instance.
- Under Resources, click Virtual Cloud Network > Security Lists.
- Add two ingress rules:
- Protocol: TCP
- Source CIDR:
0.0.0.0/0
(or restrict as needed) - Destination Port Range:
80
(for HTTP) - Repeat for port
443
(for HTTPS).
- Save the changes.
- Enable port in firewall on Ubuntu - Check below info
Ubuntu Firewall Setup - https://docs.kamlatech.in/Oracle%20Cloud/firewall
Step 5: Start PocketBase
- Start PocketBase with your domain or IP:
-
With a domain (recommended for production):
./pocketbase serve yourdomain.com
Replace
yourdomain.com
with your domain name. This enables HTTPS with Let’s Encrypt. -
With IP address (for testing, no HTTPS):
./pocketbase serve YOUR_SERVER_IP
Replace
YOUR_SERVER_IP
with your instance’s public IP.
-
- Note: Running as root allows binding to ports 80 and 443. For non-root users, see Step 7.
Step 6: Access the Admin Dashboard
- Open a web browser and navigate to:
http://YOUR_SERVER_IP:8090/_/
(if using IP).https://yourdomain.com/_/
(if using a domain).
- Follow the prompts to create your first superuser account (email and password).
Step 7: (Optional) Set Capabilities for Non-Root Users
-
To run PocketBase as a non-root user (for security), set capabilities to allow binding to privileged ports:
sudo setcap 'cap_net_bind_service=+ep' /root/pb/pocketbase
-
Create a non-root user (if not already present) and adjust permissions:
adduser pocketbase
chown -R pocketbase:pocketbase /root/pb
Step 8: Configure Email for User Registration
- Log in to the Admin Dashboard (
http://YOUR_SERVER_IP:8090/_/
orhttps://yourdomain.com/_/
). - Go to Settings > Mail settings.
- Configure SMTP settings using a third-party service. Example for MailerSend:
- Host:
smtp.mailersend.com
- Port:
465
- Encryption:
TLS
- Username: Your MailerSend API key
- Password: (Leave blank for API key-based authentication)
- Host:
- Save the settings.
- Test email functionality by creating a test user in the Users collection and verifying that registration emails are sent.
For GMAIL: you will need a App Password which is available only after enabling 2F Factor Auth
Step 9: (Optional) Set Up Systemd for Persistent Running
-
Create a Systemd service file to ensure PocketBase runs continuously:
sudo nano /lib/systemd/system/pocketbase.service
-
Add the following content:
[Unit]
Description=PocketBase Service
After=network.target
[Service]
User=root
WorkingDirectory=/pb
ExecStart=/pb/pocketbase serve yourdomain.com
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=pocketbase
Environment=PB_PUBLIC_URL=https://yourdomain.com
[Install]
WantedBy=multi-user.targetReplace
yourdomain.com
with your domain orYOUR_SERVER_IP
if using the IP address.infoRelative path to the pocketbase executabe will not work so use full path
-
Save and exit (
Ctrl+O
,Enter
,Ctrl+X
). -
Reload Systemd and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable pocketbase.service
sudo systemctl start pocketbase
Step 10: Verify Setup
- Access your PocketBase instance via the browser:
http://YOUR_SERVER_IP:8090/_/
(orhttps://yourdomain.com/_/
).
- Test user registration:
- Create a new user in the Users collection via the Admin Dashboard.
- Verify that registration emails are sent and received.
- Ensure authentication works by logging in with a test user.
Additional Notes
- Domain Name: A domain is recommended for production to enable HTTPS with Let’s Encrypt, ensuring secure connections. Without a domain, use the IP address for testing, but HTTPS won’t be available, which may impact security.
- Email Deliverability: Use a reliable SMTP service (e.g., MailerSend, SendGrid) to ensure registration and password recovery emails are delivered.
- Security: Enable Multi-Factor Authentication (MFA) for superusers in the Dashboard (
Settings
>Superusers
) for added security. - Backups: Regularly back up the
pb_data
directory (located in/root/pb
) or use PocketBase’s built-in backup APIs (Settings
>Backups
). - Oracle Cloud Free Tier: The free tier provides limited resources (e.g., 20 GB storage, 1 vCPU, 1 GB RAM for AMD instances). Ensure your data and traffic fit within these limits.
- File Storage: By default, files are stored in
pb_data/storage
. If you need more storage, configure Oracle Cloud Object Storage (20 GB free) as an S3-compatible backend.
Troubleshooting
-
Port Issues: If you can’t access PocketBase, verify that ports 80 and 443 are open in Oracle Cloud’s security lists.
-
Email Not Sending: Double-check SMTP settings and ensure your SMTP service is correctly configured.
-
Service Not Starting: Check the Systemd service status:
sudo systemctl status pocketbase
Resources
- PocketBase Official Documentation
- PocketBase GitHub Releases
- Oracle Cloud Networking Guide