Deploy Nextcloud 33 — Self-Hosted Google Drive [PG+Redis]
Own your files: Nextcloud with Postgres, Redis, S3-ready storage
Just deployed
/var/lib/postgresql/data
Nextcloud
Just deployed
/var/www/html
Bucket
Bucket
Just deployed
Deploy and Host Nextcloud on Railway
Nextcloud is the leading open-source, self-hosted file sync and collaboration platform — a private alternative to Google Drive, Dropbox, and OneDrive. Store and share files, sync across devices, and run calendar, contacts, notes, and office collaboration, all on infrastructure you control with no data leaving your servers. This template deploys the current Nextcloud 33 release with a managed PostgreSQL database and Redis cache, pre-wired and production-shaped.
What This Template Deploys
| Service | Purpose |
|---|---|
| Nextcloud | The file sync app, web UI, and admin on port 80 (nextcloud:33-apache) |
| PostgreSQL | Users, file metadata, shares, and app configuration |
| Redis | File locking, PHP session handling, and caching |
All three services run on Railway's private network with secrets auto-generated on deploy. Only Nextcloud is exposed publicly. A persistent volume holds your files.
About Hosting Nextcloud
A production Nextcloud is not a single container. It needs a real database, a cache for file locking, persistent storage, and correct trusted-domain and reverse-proxy settings — get any of them wrong and you hit untrusted-domain errors, file-lock corruption, or data loss on redeploy. This template wires all of it together so the instance comes up production-ready.
Redis is not optional here. Nextcloud uses it for transactional file locking, and without it concurrent file access from multiple devices can corrupt data. It is included and connected by default for exactly that reason. PostgreSQL replaces the SQLite default because SQLite does not hold up under real multi-user load.
Files are stored on the mounted Railway volume by default. For large libraries, Nextcloud supports S3-compatible object storage — set the OBJECTSTORE_S3_* variables to move primary storage to a bucket, which scales far better than an ever-growing volume.
Typical cost: ~$20–40/month on Railway depending on RAM and storage. For small teams, 2 GB RAM and 2 vCPUs is a realistic minimum for comfortable performance. Google Workspace runs about $6–12/user/month and Dropbox Business about $12/user/month, so Nextcloud pays off with enough seats, a data-sovereignty requirement, or the simple desire to own your file layer.
How It Compares
| Nextcloud (self-hosted) | Google Workspace | Dropbox Business | OneDrive (M365) | |
|---|---|---|---|---|
| Cost model | Flat infra ~$20–40/mo | Per user/month | Per user/month | Per user/month |
| Storage limit | Your disk / S3 bucket | Per-plan quota | Per-plan quota | Per-plan quota |
| Data ownership | Full | Vendor | Vendor | Vendor |
| Users | Unlimited | Per seat | Per seat | Per seat |
| Office suite | Built-in (Collabora) | Included | Add-on | Included |
| Self-hostable | Yes | No | No | No |
| Calendar / contacts | Built-in | Included | No | Included |
The per-seat services are simpler for a handful of users. Nextcloud wins on ownership and on cost once the team is large enough that flat infrastructure beats multiplying seats.
Deploy in Under 5 Minutes
- Click Deploy on Railway — Nextcloud, PostgreSQL, and Redis build automatically (~4–5 minutes)
- Set
NEXTCLOUD_ADMIN_USERandNEXTCLOUD_ADMIN_PASSWORDin the Variables tab - Set
NEXTCLOUD_TRUSTED_DOMAINSto your Railway domain to avoid the untrusted-domain error - Open your Railway URL, sign in, and check Settings → Administration → Overview for all-green
- Install apps (Calendar, Contacts, Talk, Office) from the App Store and add users
No reverse proxy setup, no manual Postgres or Redis wiring, no SSL configuration.
Common Use Cases
- Private Google Drive / Dropbox replacement — file sync across desktop and mobile with full data ownership
- Team file sharing and collaboration — shared folders, granular permissions, and link sharing for a whole organisation
- Self-hosted office suite — edit documents, spreadsheets, and presentations in the browser with Collabora or OnlyOffice
- Calendar and contacts server — CalDAV and CardDAV sync to replace Google Calendar and Contacts
- Personal cloud — one private home for photos, documents, and backups across all your devices
Configuration
| Variable | Required | Description |
|---|---|---|
NEXTCLOUD_ADMIN_USER | Required | Admin username, set on first run |
NEXTCLOUD_ADMIN_PASSWORD | Required | Admin password — use a strong value |
NEXTCLOUD_TRUSTED_DOMAINS | Required | Your Railway domain — Nextcloud rejects requests from untrusted domains |
POSTGRES_HOST | Auto-injected | PostgreSQL host via Railway reference variable |
POSTGRES_DB | Auto-injected | Database name |
POSTGRES_USER | Auto-injected | Database user |
POSTGRES_PASSWORD | Auto-injected | Database password |
REDIS_HOST | Auto-injected | Redis host via Railway reference variable |
REDIS_HOST_PASSWORD | Auto-injected | Redis password |
PHP_MEMORY_LIMIT | Optional | Raise to 512M for heavier workloads |
PHP_UPLOAD_LIMIT | Optional | Maximum upload size, e.g. 16G for large files |
OBJECTSTORE_S3_BUCKET | Optional | Move primary file storage to an S3-compatible bucket |
OBJECTSTORE_S3_KEY | Optional | S3 access key |
OBJECTSTORE_S3_SECRET | Optional | S3 secret key |
OBJECTSTORE_S3_ENDPOINT | Optional | S3 endpoint URL |
Set
NEXTCLOUD_TRUSTED_DOMAINSto your Railway domain. Without it, Nextcloud returns an "untrusted domain" error and blocks access. This is the single most common first-deploy issue.
Files live on the volume — back it up. Your file data and, unless you use S3, everything users upload is on the mounted volume. Losing it means losing files. Configure S3 object storage for large or important libraries.
Dependencies for Nextcloud Hosting
- Railway account — expect ~$20–40/month depending on RAM and storage
- A persistent Railway volume for file storage (included)
- Optional: S3-compatible object storage for large file libraries
- Optional: SMTP credentials for share notifications and password resets
Deployment Dependencies
Implementation Details
The template runs the official nextcloud:33-apache image on port 80 with PostgreSQL and Redis on Railway's private network. Database and Redis credentials are supplied through Railway reference variables, and all secrets are generated at deploy time. Nextcloud 33 is the current supported release line, so pinning it keeps the deployment on maintained, security-patched code.
Redis is wired in by default because Nextcloud relies on it for transactional file locking; without it, simultaneous access from multiple clients risks data corruption. PostgreSQL is used in place of the SQLite default, which does not scale to real multi-user workloads. A Railway volume persists file data across redeploys, and the OBJECTSTORE_S3_* variables allow moving primary storage to an S3 bucket when a growing volume becomes impractical.
The most common configuration pitfall is NEXTCLOUD_TRUSTED_DOMAINS: Nextcloud blocks any request whose host is not listed there, so it must be set to your Railway public domain before the instance is usable.
Frequently Asked Questions
Why does it need PostgreSQL instead of SQLite? Nextcloud defaults to SQLite for simplicity, but SQLite locks the whole database on writes and does not hold up under multi-user load. PostgreSQL handles concurrent access properly, which is why this template uses it.
Why is Redis required? Nextcloud uses Redis for transactional file locking. Without it, two clients writing at once can corrupt data. It is included and connected by default for that reason.
I get an "untrusted domain" error — how do I fix it? Set NEXTCLOUD_TRUSTED_DOMAINS to your Railway public domain in the Variables tab. Nextcloud rejects requests from any host not on that list.
Do my files survive a redeploy? Yes, because they're written to the mounted Railway volume. For large libraries, configure S3 object storage with the OBJECTSTORE_S3_* variables, which scales better than a growing volume.
How many users can it handle? With 2 GB RAM and 2 vCPUs it comfortably serves a small team of 10–50 users. Scale Railway's memory and CPU upward as your user count and file activity grow.
Can I edit documents in the browser? Yes. Install the Collabora Online or OnlyOffice app from the Nextcloud App Store for in-browser document, spreadsheet, and presentation editing.
Is this cheaper than Google Workspace? It depends on team size. Per-seat services are cheaper for a few users; Nextcloud's flat infrastructure cost wins once you have enough seats, or when data ownership is a hard requirement regardless of price.
Can I sync files to my desktop and phone? Yes. Nextcloud has official desktop clients for Windows, macOS, and Linux, and mobile apps for iOS and Android, all syncing to your instance.
Why Deploy Nextcloud 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 Nextcloud on Railway you get a complete private cloud in one click — Nextcloud, PostgreSQL, and Redis pre-wired over a private network, automatic HTTPS, a persistent volume for your files, and S3 object storage ready when you need it. Own your files, run your own office and calendar stack, and keep your data on infrastructure you control.
Template Content
Nextcloud
nextcloudNEXTCLOUD_ADMIN_USER
Username for the initial Nextcloud admin account
NEXTCLOUD_ADMIN_PASSWORD
Password for the initial Nextcloud admin account
Bucket
Bucket