Hands-on VPS & self-hosting Monday, June 1, 2026
VPS.app
Hands-on VPS benchmarks and self-hosting guides — tested, not theorized.
Self-Hosting Guides

How to Self-Host Nextcloud on a VPS (2026, Docker)

Some links below are affiliate links: if you buy through them I may earn a commission at no extra cost to you. I only recommend what I have actually tested, and it never changes my verdict.

Self-hosted cloud file storage

Nextcloud turns a cheap VPS into your own file cloud: file sync across devices, calendar, contacts, notes, and photo backup — without a monthly per-GB bill. This guide uses Docker Compose, which is the least painful way to run and keep it updated.

Why self-host Nextcloud instead of using Google Drive?

Three reasons people make the switch:

  • You own the data. It lives on a server you control, not in someone else’s account that can be suspended or scanned.
  • No per-GB subscription. You pay only for the VPS. Storing 500 GB costs the same as storing 5 GB until the disk fills up.
  • It’s more than storage. Nextcloud also does calendar, contacts, notes, and phone photo backup — a small private cloud, not just a drive.

The trade-off is honest: you maintain it. That’s updates, backups, and the occasional bit of troubleshooting. This guide is built so that trade-off stays small.

Prerequisites

Step 1 — Create the Compose file

Create a folder and a docker-compose.yml:

services:
  db:
    image: mariadb:11
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: change_me_root
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: change_me

  app:
    image: nextcloud:stable
    restart: always
    ports:
      - "8080:80"
    depends_on:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: change_me
      NEXTCLOUD_ADMIN_USER: admin
      NEXTCLOUD_ADMIN_PASSWORD: change_me_admin
      NEXTCLOUD_TRUSTED_DOMAINS: cloud.yourdomain.com

volumes:
  db:
  nextcloud:

Change every change_me* value and set NEXTCLOUD_TRUSTED_DOMAINS to your real subdomain. The two named volumes (db, nextcloud) are where your data lives — remember them, because they’re what you back up later.

Step 2 — Start it

docker compose up -d
docker compose logs -f app   # watch until it's ready

Nextcloud is now listening on port 8080 on the server — but only locally; it’s not safely public yet.

Step 3 — Add HTTPS with a reverse proxy

Don’t expose port 8080 directly. Put Nginx Proxy Manager in front, point cloud.yourdomain.comhttp://app:80 (or the host’s :8080), and let it issue a free Let’s Encrypt certificate. Full walkthrough: Nginx Proxy Manager setup.

This is the step that turns “running on a port” into “a real, encrypted site you can log into from your phone.”

Step 4 — First-run setup

Open https://cloud.yourdomain.com, log in with the admin user you set, and install the apps you want (Calendar, Contacts, Notes, Photos). For better performance with several users, add Redis for file locking — but the stack above is fine to start.

Step 5 — Back it up (don’t skip this)

A self-hosted cloud you can’t restore is a liability. Back up two things:

  1. The data volume (nextcloud) — your actual files.
  2. The database — a mysqldump of the nextcloud database.

The simplest reliable setup is a nightly cron job that dumps the database and syncs both to off-site object storage like Backblaze B2 or S3. Keeping backups on the same server defeats the purpose — if the box dies, so do they.

Troubleshooting

  • “Access through untrusted domain” — your domain isn’t in NEXTCLOUD_TRUSTED_DOMAINS. Fix the value and run docker compose up -d again.
  • 502 / bad gateway from the proxy — the proxy is pointing at the wrong container name or port. It should target the app container on port 80.
  • Uploads of large files fail — raise the proxy’s client_max_body_size and PHP upload limits; the default caps are low.
  • Slow first load — small boxes benefit from adding Redis for caching and file locking once you have a few users.

Which VPS to run it on

Nextcloud is light for one person but disk-hungry once you sync photos. A 2 GB managed instance on Cloudways is the hands-off option; a cheap Hetzner box is the best value if you’re comfortable on the CLI. Full comparison: Best VPS for Self-Hosting. For low-latency access from mainland China, see the BandwagonHost HK review.

Once Nextcloud is running, the same VPS can host more: a password manager (Vaultwarden) or a Google Photos replacement (Immich) sit happily alongside it.

Frequently asked questions

What VPS specs do I need for Nextcloud?

For personal use (a few users), 2 vCPU / 2 GB RAM and 40 GB+ disk is comfortable. Heavy use (photos, many users, on-the-fly previews) wants 4 GB+ and more disk.

Is self-hosting Nextcloud hard?

With Docker Compose it's about 20 minutes: paste a compose file, run one command, then point a domain and add HTTPS via a reverse proxy. No manual PHP/Apache tuning required.

How do I get HTTPS for Nextcloud?

Put a reverse proxy in front (Nginx Proxy Manager is the easiest) and let it issue a free Let's Encrypt certificate for your domain. See the linked reverse-proxy guide.

Nextcloud vs Google Drive — why self-host?

You own the data, there's no per-GB subscription (you pay only for the VPS), and you can add apps (calendar, contacts, notes, photo backup). The trade-off is you maintain it yourself.

How do I back up a self-hosted Nextcloud?

Back up two things: the data volume (your files) and the database. The simplest approach is a nightly job that dumps the MariaDB database and copies both to off-site object storage like Backblaze B2 or S3.