Skip to content

How to Deploy Syncthing on a VPS

Updated Nov 2026

verified on Ubuntu 26.04 · Nov 2026
We earn commissions when you shop through the links below. Full disclosure →

Run Syncthing on a VPS as an always-on sync peer with Docker Compose, a password-protected GUI behind Caddy HTTPS, and a tested restore.

Before you start
  • A VPS with disk for the files you sync (see Server sizing below)
  • A fresh Ubuntu 26.04 server with root/sudo SSH access
  • A domain or subdomain you can point at the server
  • Syncthing on at least one other device
Need a box for this guide? Kamatera's free tier lets you spin one up now.Start free on Kamatera → (opens in new tab)

What you are building

Syncthing syncs folders directly between your devices. A VPS adds a peer that is always online, a common way to replace part of Dropbox. Sync is not backup: a deletion on one device is synced to the others. For a web file manager with sharing links, see Nextcloud or Seafile.

Server sizing

On the catalog's test box Syncthing measured about 21 MB of memory idle and about 70 MB of disk. Large folders with many files need more memory while scanning, and the disk must hold everything the VPS syncs.

Prepare the server

Update the system and install the tools this guide uses:

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y curl openssl ufw dnsutils

If you're logged in as root, create a non-root sudo user and continue as that user:

adduser deploy
usermod -aG sudo deploy

Open SSH, the two ports the reverse proxy needs and Syncthing's sync port:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 22000/tcp
sudo ufw allow 22000/udp
sudo ufw --force enable

Both containers below use host networking, so ufw does apply to them. The Syncthing web GUI listens on loopback only and gets no public port of its own.

Where to host itaffiliate disclosure
Hetzner Cloudrun it on
2 vCPU · 4 GB RAM · 80 GB SSD · $23.59/mo
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
1 vCPU · 1 GB RAM · 20 GB SSD · $4.00/mo
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
1 vCPU · 1 GB RAM · 25 GB SSD · $6.00/mo
Deploy on DigitalOcean → (opens in new tab)

Paid link — we earn a commission if you shop through it.

Install Docker

If Docker isn't on the server yet, the convenience script installs Docker Engine and the Compose plugin (the Docker and Compose on Ubuntu guide covers the details):

command -v docker >/dev/null || curl -fsSL https://get.docker.com | sudo sh
sudo docker compose version

Port 22000 is Syncthing's sync protocol, which authenticates devices by their certificates. It has to be reachable for direct connections (open it in your provider's firewall too); without it devices fall back to relays.

Configure the stack

Replace sync.example.com with your hostname. Syncthing runs as your user so the synced files belong to you:

mkdir -p ~/syncthing/data && cd ~/syncthing
DOMAIN=sync.example.com
[ -f .env ] || ( umask 077
  { echo "DOMAIN=$DOMAIN"
    echo "PUID=$(id -u)"
    echo "PGID=$(id -g)"
    echo "GUI_PASSWORD=$(openssl rand -hex 16)"
  } > .env )

Host networking follows the upstream Docker instructions, because bridge mode breaks local discovery. STGUIADDRESS= (empty) makes the GUI listen on 127.0.0.1:8384 only, and Caddy, also on the host network, is the way in. Caddy rewrites the Host header as Syncthing's reverse-proxy documentation shows, otherwise Syncthing rejects the request.

cd ~/syncthing
cat > docker-compose.yml <<'EOF'
services:
  syncthing:
    image: syncthing/syncthing:2.1.7
    hostname: vps
    restart: unless-stopped
    network_mode: host
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      STGUIADDRESS: ""
    volumes:
      - ./data:/var/syncthing
  caddy:
    image: caddy:2
    restart: unless-stopped
    network_mode: host
    environment:
      DOMAIN: ${DOMAIN}
    volumes: ["./Caddyfile:/etc/caddy/Caddyfile:ro", "caddy_data:/data"]
volumes:
  caddy_data:
EOF
cat > Caddyfile <<'EOF'
{$DOMAIN} {
    reverse_proxy 127.0.0.1:8384 {
        header_up Host {upstream_hostport}
    }
}
EOF

Set the GUI password before the first start

The GUI has no password by default, and you are about to put it on the internet. Generate the device keys and set the login before anything listens. The password goes in on standard input:

cd ~/syncthing
. ./.env
printf '%s\n' "$GUI_PASSWORD" | sudo docker compose run --rm -T syncthing generate --gui-user=admin --gui-password=-
sudo docker compose up -d
code=000
for i in $(seq 1 30); do
  code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8384/rest/noauth/health)
  [ "$code" = 200 ] && break
  sleep 3
done
echo "health: $code"; [ "$code" = 200 ]

HTTPS and the domain

Create an A record for your hostname pointing at the server's public IP and confirm it resolves before Caddy asks for a certificate:

dig +short sync.example.com

Caddy requests the certificate once the name resolves and renews it on its own (see Automatic HTTPS with Caddy). The API must refuse anonymous requests (403), and the login must accept your password (204) and refuse a wrong one (403):

. ~/syncthing/.env
code=000
for i in $(seq 1 30); do
  code=$(curl -s -o /dev/null -w '%{http_code}' "https://$DOMAIN/rest/noauth/health")
  [ "$code" = 200 ] && break
  sleep 5
done
anon=$(curl -s -o /dev/null -w '%{http_code}' "https://$DOMAIN/rest/system/status")
auth=$(printf '{"username":"admin","password":"%s"}' "$GUI_PASSWORD" | curl -s --data @- -H 'Content-Type: application/json' -o /dev/null -w '%{http_code}' "https://$DOMAIN/rest/noauth/auth/password")
wrong=$(curl -s -d '{"username":"admin","password":"wrong"}' -H 'Content-Type: application/json' -o /dev/null -w '%{http_code}' "https://$DOMAIN/rest/noauth/auth/password")
echo "health $code, anonymous $anon, right password $auth, wrong password $wrong"
[ "$code" = 200 ] && [ "$anon" = 403 ] && [ "$auth" = 204 ] && [ "$wrong" = 403 ]

Connect your devices

Print the server's device ID:

cd ~/syncthing
sudo docker compose exec -T syncthing syncthing device-id | tee ~/syncthing/device-id.txt

Open https://sync.example.com and sign in as admin with GUI_PASSWORD from .env. Add your laptop under Add Remote Device, add the VPS's ID on the laptop, and accept the request on both sides. Share folders with paths under /var/syncthing/, which is ~/syncthing/data on the host. This creates one folder from the command line, with a file in it:

cd ~/syncthing
mkdir -p data/docs && echo "restore me" > data/docs/hello.txt
sudo docker compose exec -T syncthing syncthing cli config folders add --id docs --path /var/syncthing/docs
sudo docker compose exec -T syncthing syncthing cli config folders list

Backups

What matters is the device identity (cert.pem, key.pem), config.xml and your files. The index database is deliberately left out: Syncthing rebuilds it by scanning, and a stale copy describes files as they were at backup time.

cd ~/syncthing
sudo docker compose stop syncthing
( umask 077; sudo tar czf - --exclude='data/config/index-*' data .env docker-compose.yml Caddyfile device-id.txt > ~/syncthing-backup.tar.gz )
sudo docker compose start syncthing
ls -lh ~/syncthing-backup.tar.gz

Copy it off the server. It contains the private key and every synced file.

Restore

This replaces the current data directory. On a new server, unpack into ~/syncthing before starting anything. Never run the old and restored copies of one device ID at the same time. If peers have changed files since the backup, set the restored folder to Receive Only or pause it and check before letting it sync.

The block checks the archive first and stops at the first error.

(
  set -e
  cd ~/syncthing
  tar tzf ~/syncthing-backup.tar.gz >/dev/null
  sudo docker compose stop syncthing
  sudo rm -rf data
  sudo tar xzf ~/syncthing-backup.tar.gz
  sudo docker compose up -d
  for i in $(seq 1 30); do curl -sf -o /dev/null http://127.0.0.1:8384/rest/noauth/health && break; sleep 3; done
  sudo docker compose exec -T syncthing syncthing device-id | diff - device-id.txt
  echo "same device ID"
)
cd ~/syncthing
sudo docker compose exec -T syncthing syncthing cli config folders list | grep -x docs
grep -x 'restore me' data/docs/hello.txt

Upgrades

The container does not self-update; you change the tag. Read the release notes, back up, edit the tag (this guide pins 2.1.7), then:

cd ~/syncthing
sudo docker compose pull
sudo docker compose up -d
sudo docker compose ps

Troubleshooting

cd ~/syncthing && sudo docker compose logs --tail=100 syncthing caddy
sudo ss -tulpn | grep -E ':(22000|8384)'

Host check error means the header_up Host line is missing from the Caddyfile.

Next steps

Compare providers in Best VPS for self-hosting.

Next steps

Common questions

How long does it take to follow "How to Deploy Syncthing on a VPS"?

We estimate about 25 minutes of hands-on time for "How to Deploy Syncthing on a VPS"; this is an editorial estimate, not a measurement.

Was the "How to Deploy Syncthing on a VPS" guide tested?

The "How to Deploy Syncthing on a VPS" guide was verified end-to-end on Ubuntu 26.04 (Nov 2026).

Analytics cookies only (Google Analytics, PostHog). No ad networks, no cross-site tracking. See our privacy policy.