Railway

Deploy Nextcloud 33 — Self-Hosted Google Drive [PG+Redis]

Own your files: Nextcloud with Postgres, Redis, S3-ready storage

Deploy Nextcloud 33 — Self-Hosted Google Drive [PG+Redis]

/var/lib/postgresql/data

Nextcloud

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

ServicePurpose
NextcloudThe file sync app, web UI, and admin on port 80 (nextcloud:33-apache)
PostgreSQLUsers, file metadata, shares, and app configuration
RedisFile 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 WorkspaceDropbox BusinessOneDrive (M365)
Cost modelFlat infra ~$20–40/moPer user/monthPer user/monthPer user/month
Storage limitYour disk / S3 bucketPer-plan quotaPer-plan quotaPer-plan quota
Data ownershipFullVendorVendorVendor
UsersUnlimitedPer seatPer seatPer seat
Office suiteBuilt-in (Collabora)IncludedAdd-onIncluded
Self-hostableYesNoNoNo
Calendar / contactsBuilt-inIncludedNoIncluded

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

  1. Click Deploy on Railway — Nextcloud, PostgreSQL, and Redis build automatically (~4–5 minutes)
  2. Set NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD in the Variables tab
  3. Set NEXTCLOUD_TRUSTED_DOMAINS to your Railway domain to avoid the untrusted-domain error
  4. Open your Railway URL, sign in, and check Settings → Administration → Overview for all-green
  5. 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

VariableRequiredDescription
NEXTCLOUD_ADMIN_USERRequiredAdmin username, set on first run
NEXTCLOUD_ADMIN_PASSWORDRequiredAdmin password — use a strong value
NEXTCLOUD_TRUSTED_DOMAINSRequiredYour Railway domain — Nextcloud rejects requests from untrusted domains
POSTGRES_HOSTAuto-injectedPostgreSQL host via Railway reference variable
POSTGRES_DBAuto-injectedDatabase name
POSTGRES_USERAuto-injectedDatabase user
POSTGRES_PASSWORDAuto-injectedDatabase password
REDIS_HOSTAuto-injectedRedis host via Railway reference variable
REDIS_HOST_PASSWORDAuto-injectedRedis password
PHP_MEMORY_LIMITOptionalRaise to 512M for heavier workloads
PHP_UPLOAD_LIMITOptionalMaximum upload size, e.g. 16G for large files
OBJECTSTORE_S3_BUCKETOptionalMove primary file storage to an S3-compatible bucket
OBJECTSTORE_S3_KEYOptionalS3 access key
OBJECTSTORE_S3_SECRETOptionalS3 secret key
OBJECTSTORE_S3_ENDPOINTOptionalS3 endpoint URL

Set NEXTCLOUD_TRUSTED_DOMAINS to 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

nextcloud

Bucket

Bucket

More templates in this category

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

PROJETOS
7
View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Artour
7
View Template
ReadySet
A lightweight caching engine for Postgres

Milo
35