Self-host Nextcloud on Railway as a Drive or Dropbox alternative
Short answer: deploy Nextcloud on Railway to run your own file sync and sharing service, with calendars and contacts included. Tracklayer’s template runs Nextcloud 34.0.4 with PostgreSQL 18 and Redis, installs itself on first start with a generated admin password, and lets you keep files on a volume or in a Railway Bucket. Choose the storage option before the first deploy, because it cannot be changed afterwards.
Deploy Nextcloud on RailwayWhen Nextcloud makes sense
Nextcloud is an open-source cloud for files, calendars and contacts that you run yourself. People use it for:
- a private Dropbox or Google Drive replacement for a family, club or small company,
- calendar and contact sync for phones and desktops through CalDAV and CardDAV,
- sharing files with clients through password-protected links,
- a team file server with desktop sync clients and mobile apps.
You are the administrator, so you also own updates, backups and user accounts.
What the template deploys
| Service | Image | Role |
|---|---|---|
| Nextcloud | nextcloud:34.0.4-apache |
Web UI, WebDAV, CalDAV, CardDAV and cron |
| Postgres | postgres-ssl:18 |
Database |
| Redis | redis:8.2 |
File locking, cache, sessions |
| Bucket | Railway Bucket | Optional primary storage |
Background jobs run from cron inside the Nextcloud container, because a Railway volume belongs to one service. The first start also installs the Calendar and Contacts apps and trusts Railway’s proxy, so links use HTTPS.
Deploy Nextcloud, step by step
These steps use Tracklayer’s Nextcloud 34 template.
- Decide where files go.
NEXTCLOUD_PRIMARY_STORAGEisvolumeby default. Set it tobucketbefore the first deploy if you expect more than a few GB. See the next section. - Deploy the template. The first start takes about two minutes.
- Find your login. Open the Nextcloud service, then Variables, and copy
NEXTCLOUD_ADMIN_PASSWORD. - Sign in as
admin. Change the password straight away. - Create accounts. Add a user for each person instead of sharing the admin login.
- Connect clients. Point the desktop and mobile sync apps, and your calendar and contacts apps, at your Railway domain.
- Optional: add a custom domain. Add it to
NEXTCLOUD_TRUSTED_DOMAINS(space-separated), setOVERWRITECLIURLtohttps://your-domainand redeploy.
Volume or Bucket
This is the main decision to make up front.
- Volume (default): files live on the Nextcloud service’s volume. The Hobby plan caps a volume at 5 GB, and Nextcloud’s code and apps take about 1 GB of it, so plan on about 4 GB of files. Pro volumes are larger.
- Bucket: files go to a Railway Bucket with no size cap. Storage is billed per GB.
The choice is locked after installation, so decide before you deploy.
Persistence
Files are on the volume or in the Bucket, and the database is in Postgres, so your data is kept across redeploys. Back up the database and your files before any upgrade.
Cost
Memory and storage drive the cost. The template documents:
- Measured locally after install and a test upload: Nextcloud 197 MiB, Postgres 63 MiB, Redis 5 MiB.
- Estimated: about $4 a month idle. For a household or small team of 5 to 20 users with sync clients, about $10 to $30 a month, plus storage. Storage is estimated at $0.15 per GB on the volume or $0.015 per GB in the Bucket. These figures use the Railway prices listed in the template’s TEMPLATE.md and can change.
- Plan guidance from the template: Hobby at minimum. Pro is needed for larger volumes or outbound SMTP.
For more simultaneous users, give the service more memory and raise APACHE_MAX_REQUEST_WORKERS. The README puts each worker at about 100 MB.
Limitations and licence
- Email: needs SMTP, which Railway allows on the Pro plan only.
- Storage choice: locked after installation.
- Scaling: Nextcloud runs as one service with its volume.
- Licence: AGPL-3.0, as listed in the template’s NOTICE. Read it if you plan to modify and offer the software to others.
- Affiliation: a community template, not affiliated with or endorsed by Nextcloud GmbH.
Upgrades
The version is the FROM line in services/nextcloud/Dockerfile in the template. Upgrade one major version at a time, for example 34 to 35, then 35 to 36. The container runs the upgrade on start.
Other options
If you mainly need notebooks rather than file sync, see the JupyterLab template. For team docs and whiteboards, see the AFFiNE template. More walkthroughs are listed under guides.
FAQ
How do I log in to Nextcloud after deploying?
After the first deploy, which takes about two minutes, open the domain and sign in as admin with the password in the NEXTCLOUD_ADMIN_PASSWORD variable. Change it, then create accounts for your users.
Should I store files on the volume or in a Bucket?
The default, NEXTCLOUD_PRIMARY_STORAGE=volume, is limited to 5 GB on the Hobby plan, including about 1 GB for Nextcloud itself. Set it to bucket before the first deploy to store files in a Railway Bucket without a size cap. The choice is locked after installation.
Will Nextcloud email work on Railway?
Nextcloud sends email over SMTP, which Railway allows on the Pro plan. Set the SMTP_* and MAIL_* variables, or configure it under Administration, then Basic settings.
What licence is Nextcloud under?
The template's NOTICE lists the Nextcloud server and its Docker image as AGPL-3.0. AGPL has conditions if you modify the software and offer it to others, so read the licence or ask a lawyer if you plan to do that. This is a community template, not affiliated with or endorsed by Nextcloud GmbH.
How do I use a custom domain?
Add the domain to NEXTCLOUD_TRUSTED_DOMAINS, set OVERWRITECLIURL to https://your-domain and redeploy.