Self-Hosted File Sync with Syncthing: A Complete Guide

Ditch the cloud and take control of your file synchronization with Syncthing. Learn how to set up secure, private P2P sync across all your devices.

• 7 min read
homelabself-hostedsyncthingfile-syncdocker
Self-Hosted File Sync with Syncthing: A Complete Guide

If you’ve ever wished you could sync files between your devices without trusting a third-party cloud provider, Syncthing is the answer. This open-source, peer-to-peer file synchronization tool gives you complete control over your data while keeping it synchronized across all your machines.

After years of using cloud services like Dropbox and Google Drive, I made the switch to Syncthing in my homelab. The result? Faster syncs, no monthly fees, and complete privacy. Here’s everything you need to know to get started.

Why Syncthing?

Traditional cloud storage services have a fundamental problem: your data lives on someone else’s servers. Even with encryption at rest, you’re trusting a company with your files, paying monthly fees, and dealing with storage limits.

Syncthing takes a different approach. It syncs your files directly between your own devices using end-to-end encryption. No middleman. No cloud. Just your machines talking to each other.

Key benefits:

  • Privacy: Your data never leaves your network (unless you want it to)
  • No storage limits: Sync as much as your hard drives can hold
  • No monthly fees: It’s completely free and open source
  • Cross-platform: Works on Windows, macOS, Linux, Android, and more
  • Fast: Block-level sync only transfers what changed

How Syncthing Works

Syncthing uses a peer-to-peer architecture. Each device runs the Syncthing software and maintains a list of trusted devices. When you add a folder to share, Syncthing establishes encrypted connections to your other devices and begins synchronizing.

The magic is in the details:

  1. Device IDs: Each installation generates a unique cryptographic ID used for authentication
  2. Mutual trust: Both devices must explicitly add each other before syncing
  3. Block-level sync: Only changed portions of files transfer, not entire files
  4. Conflict resolution: Built-in versioning handles simultaneous edits gracefully

Installing Syncthing with Docker

The cleanest way to run Syncthing in a homelab is via Docker. Here’s a production-ready docker-compose.yml:

services:
  syncthing:
    image: linuxserver/syncthing:latest
    container_name: syncthing
    hostname: syncthing-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
    volumes:
      - ./config:/config
      - /mnt/storage/sync:/data
    ports:
      - "8384:8384"      # Web UI
      - "22000:22000/tcp"  # Sync protocol (TCP)
      - "21027:21027/udp"  # Discovery (UDP)
    restart: unless-stopped

Important configuration notes:

  • PUID and PGID should match your host user IDs (run id -u and id -g to find them)
  • Mount your storage location to /data for synced files
  • The /config volume stores your device ID and settings persistently

Start with:

docker compose up -d
docker compose logs -f  # Watch for startup messages

Initial Configuration

Once running, access the web interface at http://your-server:8384. The first thing you’ll see is a warning about setting a GUI password—do this immediately.

Setting Up Security

  1. Click ActionsSettingsGUI
  2. Set a strong username and password
  3. Enable HTTPS if you’ll access the GUI remotely
  4. Consider binding to 0.0.0.0 only if you need remote access

Getting Your Device ID

Your Device ID is how other devices find and authenticate with this installation. To find it:

  1. Click ActionsShow ID
  2. Copy the long alphanumeric string
  3. You’ll need this ID when adding this device to others

Connecting Your First Device

Let’s connect two devices—a server and a laptop:

On the Server

  1. Click Add Remote Device (bottom right)
  2. Enter your laptop’s Device ID
  3. Give it a recognizable name like “MacBook Pro”
  4. Leave the defaults and click Save

On the Laptop

  1. Install Syncthing (via package manager, brew, or download)
  2. Access http://localhost:8384
  3. You’ll see a prompt: “Device [server-id] wants to connect”
  4. Click Add Device to accept the connection

The connection is now mutual and encrypted.

Sharing Your First Folder

With devices connected, you need to share folders:

On the Source Device

  1. Click Add Folder
  2. Set a Folder Label (e.g., “Documents”)
  3. Set the Folder Path (e.g., /data/documents)
  4. Click Sharing and check the target device
  5. Click Save

On the Target Device

  1. You’ll see a prompt: “Share folder ‘Documents’?”
  2. Click Add and set a local path
  3. Click Save to confirm

You can also set folder types:

  • Send & Receive: Two-way sync (default)
  • Send Only: This device sends changes but ignores incoming ones
  • Receive Only: This device receives changes but doesn’t send local modifications

Homelab Use Cases

After running Syncthing for over a year, here are my most valuable syncing scenarios:

1. Photo Backup from Phone

Enable auto-sync from your phone’s camera roll to a receive-only folder on your NAS. Every photo you take automatically appears on your server—no cloud subscription required.

2. Server Configuration Sync

Keep configuration directories synced across your homelab servers:

  • /etc/nginx/sites-enabled synced across nginx clusters
  • Docker compose files replicated for redundancy
  • Prometheus/Grafana dashboards available everywhere

3. Development Projects

Sync active projects between your workstation and a build server. Changes on your laptop appear instantly on the build machine.

4. Password Database

If you use KeePassXC or similar, sync your .kdbx file across all devices. Changes sync instantly, and file versioning protects against corruption.

5. Media Libraries

Sync downloaded media or transcoded files from a processing server to your media storage.

File Versioning: Your Safety Net

One of Syncthing’s most powerful features is built-in file versioning. When a file changes, Syncthing can keep old versions before overwriting.

Versioning Strategies

TypeBest ForHow It Works
Trash CanSimple protectionMoves deleted files to .stversions folder
SimpleLimited historyKeeps last N versions of each file
StaggeredLong-term protectionKeeps versions at increasing intervals
ExternalCustom workflowsRuns a script for each version

I recommend Staggered File Versioning for most use cases:

  • Keeps versions for up to 1 year
  • Uses 1 per hour for first day, 1 per day for first month, 1 per week after
  • Prevents catastrophic data loss from accidental deletes or ransomware

Enable it in folder settings under File Versioning.

Performance Tips

Block-Level Sync

Syncthing only transfers changed blocks within files, not entire files. This makes it incredibly efficient for large files like VM images or video projects.

Scan Intervals

By default, Syncthing rescans folders every 60 seconds. For actively-changing directories, reduce this:

  1. Edit folder settings
  2. Advanced → Rescan Interval
  3. Set to 10 for near-real-time sync

For static folders, increase to 3600 (1 hour) to save CPU.

Ignore Patterns

Use .stignore files to exclude files from sync:

# Common exclusions
.DS_Store
*.bak
node_modules/
.git/
*.tmp

Place .stignore in the root of any shared folder.

Security Best Practices

Local Network Only

If you only sync within your home network, disable external discovery:

  1. Actions → Settings → Connections
  2. Uncheck Global Discovery
  3. Uncheck Enable Relays

This prevents your device IDs from being shared with public servers.

Self-Hosted Discovery

For remote access without exposing your IP, run your own discovery server:

docker run -d \
  --name syncthing-discovery \
  -p 8443:8443 \
  syncthing/discosrv

Then configure your devices to use your discovery server instead of the public ones.

HTTPS for GUI

Enable encrypted GUI access:

  1. Actions → Settings → GUI
  2. Check Use HTTPS
  3. Restart Syncthing
  4. Access via https://your-server:8384

Comparison: Syncthing vs Alternatives

FeatureSyncthingResilio SyncNextcloud
LicenseOpen SourceProprietaryOpen Source
ArchitectureP2PP2PClient-Server
CostFreeFree tier + PaidFree (self-hosted)
EncryptionEnd-to-endEnd-to-endServer-side
Mobile SupportAndroid officialFull supportFull support
Setup ComplexityModerateEasyHigher

Choose Syncthing if: You want open-source, transparent software with no vendor lock-in.

Choose Resilio Sync if: You need faster performance with very large files and don’t mind proprietary software.

Choose Nextcloud if: You want a full suite including calendar, contacts, and collaboration tools alongside file sync.

Common Issues and Solutions

Connection Fails Between Devices

Symptoms: Devices show as “Disconnected” or “Unknown”

Solutions:

  1. Check firewall rules (ports 22000 TCP, 21027 UDP)
  2. Verify Device IDs match on both ends
  3. Ensure time is synced (NTP) on both devices
  4. Check if Symmetric NAT is blocking connections

Sync is Slow

Solutions:

  1. Reduce rescan interval for active folders
  2. Check network bandwidth between devices
  3. Enable “Use Large Blocks” in Advanced settings for large files
  4. Reduce concurrent requests if CPU is limiting

High CPU Usage

Solutions:

  1. Increase rescan interval for static folders
  2. Add more patterns to .stignore
  3. Limit concurrent connections in Advanced settings
  4. Consider running on dedicated low-power hardware

The Verdict

After a year of daily use, Syncthing has become an indispensable part of my homelab. It replaced my Dropbox subscription, gave me control over my data, and works reliably across all my devices.

The initial setup takes some learning, but once configured, it runs silently in the background. File versioning has saved me multiple times from accidental deletions. The ability to sync between servers without exposing anything to the internet provides peace of mind.

If you value privacy, control, and avoiding monthly fees, Syncthing deserves a spot in your homelab toolkit. Your data stays yours—exactly where it belongs.


Ready to get started? The official Syncthing documentation has detailed guides for every platform. For homelab deployments, the Docker approach above is the cleanest path to a production setup.

Anthony Lattanzio

Anthony Lattanzio

Tech Enthusiast & Builder

I'm a tech enthusiast who loves building things with hardware and software. By night, I run a homelab that's grown way beyond what any reasonable person needs. Check out about me for more.

Comments

Powered by GitHub Discussions