Self-Hosting Obsidian LiveSync
On a Free VPS: Syncthing, Dead Ends, and Finally CouchDB
Tags: obsidian, self-hosting, docker, caddy, couchdb, oracle-cloud
[IMAGE: Hero shot. Obsidian open on a Windows laptop and an Android phone side by side, same note on both screens]
I wanted my Obsidian notes to sync between my Windows laptop and my Android phone, without paying for Obsidian Sync and without handing my notes to a third party. I already had a spare Oracle Cloud VM, so the plan was to make that the central server.
It took one evening, three false starts, and a handful of Docker permission errors. This post documents the whole journey, including the wrong turns, because the wrong turns are where I learned the most.
The goal
- Edit notes on Windows and Android, with changes showing up on the other device within seconds
- A self-hosted server I fully control
- Nothing extra to install on the laptop or phone beyond Obsidian itself
- Support for images and audio recordings, not just text
- A server setup I can reuse for other projects later
The setup I ended up with
PieceRoleOracle Cloud free VM (Ubuntu)Hosts everythingDocker ComposeRuns the servicesCouchDBStores the synced vaultCaddyReverse proxy with automatic HTTPSDuckDNSFree domain nameSelf-hosted LiveSync pluginThe Obsidian side of the sync
[IMAGE: Architecture diagram. Obsidian (Windows) and Obsidian (Android) → HTTPS → Caddy → CouchDB on the VPS]
Detour 1: Syncthing (and why I dropped it)
My first idea was Syncthing, a peer-to-peer file sync tool. It's free, simple, and works well. I even got as far as running it in Docker on the VPS and getting the web UI up through an SSH tunnel.
[SCREENSHOT: Syncthing web UI on the VPS, showing the Device ID screen]
Then the dealbreaker became clear. Syncthing needs an app installed and running on every device. On Windows I'd have to install Syncthing (or a tray wrapper) and keep it running, and on Android I'd need a separate app. I wanted the VPS to be the central server, with Obsidian itself talking to it and nothing else installed anywhere.
That requirement points to a different tool: the Self-hosted LiveSync community plugin for Obsidian, which syncs through a CouchDB database.
Lesson: decide your "nothing extra installed" requirement before choosing the tool. It rules out a whole category.
Detour 2: The firewall maze
Before switching, I had also already hit the firewall problem, and it's worth documenting because it came back later.
My VPS runs on Oracle Cloud, which has two firewalls:
- The host firewall (plain iptables on this image, no UFW or firewalld)
- Oracle's cloud firewall (Security Lists in the VCN)
You can check the host side with:
sudo ufw status
sudo firewall-cmd --state
sudo iptables -L -n
[SCREENSHOT: Oracle Cloud console, Security List ingress rules]
Out of laziness, I'd opened ports 8000-9000 in Oracle's console so I wouldn't have to keep adding rules. That worked for a while, and I even planned a setup around it: Caddy on port 8443 using a DNS challenge for certificates, because Let's Encrypt's normal check needs ports 80 and 443.
That plan needed a custom Caddy build with the DuckDNS module. It was a lot of machinery. Then I remembered that ports 80 and 443 were already open on both firewalls from an older project (a container I'd since removed). Once I confirmed nothing was using them anymore, the whole DNS-challenge setup became unnecessary. Stock Caddy on 80/443 just works.
Lesson: check what you've already opened before designing around a limitation that doesn't exist.
The final architecture
Two Docker Compose projects sharing one Docker network:
~/caddy: a shared reverse proxy for all future projects~/livesync: CouchDB, with no published ports (only Caddy can reach it)
DuckDNS gave me yourname.duckdns.org, and sub-subdomains like notes.yourname.duckdns.org resolve to the same IP automatically. So every future project can get its own HTTPS subdomain with no extra DNS work.
Step 1: DuckDNS
Create a subdomain at duckdns.org and point it at the VPS public IP. Confirm that the subdomain resolves:
getent hosts notes.yourname.duckdns.org
curl -s https://api.ipify.org # should match
Step 2: Shared network and folders
docker network create proxy
mkdir -p ~/livesync/{couchdb-data,couchdb-config}
mkdir -p ~/caddy/{data,config,sites}
Step 3: CouchDB config
~/livesync/.env:
COUCHDB_USER=admin
COUCHDB_PASSWORD=use-a-long-random-password
~/livesync/couchdb-config/local.ini:
[couchdb]
single_node = true
max_document_size = 50000000
[chttpd]
require_valid_user = true
max_http_request_size = 4294967296
enable_cors = true
[chttpd_auth]
require_valid_user = true
authentication_redirect = /_utils/session.html
[httpd]
WWW-Authenticate = Basic realm="couchdb"
enable_cors = true
[cors]
origins = app://obsidian.md,capacitor://localhost,http://localhost
credentials = true
headers = accept, authorization, content-type, origin, referer
methods = GET, PUT, POST, HEAD, DELETE
max_age = 3600
The CORS origins matter: app://obsidian.md is the desktop app and capacitor://localhost is the mobile app.
~/livesync/docker-compose.yml:
services:
couchdb:
image: couchdb:latest
container_name: couchdb
restart: unless-stopped
environment:
- COUCHDB_USER=${COUCHDB_USER}
- COUCHDB_PASSWORD=${COUCHDB_PASSWORD}
volumes:
- ./couchdb-data:/opt/couchdb/data
- ./couchdb-config/local.ini:/opt/couchdb/etc/local.d/10-livesync.ini
networks:
- proxy
networks:
proxy:
external: true
Step 4: Caddy
~/caddy/docker-compose.yml:
services:
caddy:
image: caddy:latest
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./data:/data
- ./config:/config
- ./sites:/srv
networks:
- proxy
networks:
proxy:
external: true
~/caddy/Caddyfile:
notes.yourname.duckdns.org {
reverse_proxy couchdb:5984
}
# Docker app (container must join the "proxy" network):
# app.yourname.duckdns.org {
# reverse_proxy myapp:3000
# }
# Static site (files in ~/caddy/sites/blog):
# blog.yourname.duckdns.org {
# root * /srv/blog
# file_server
# }
To add a project later, add a block and reload without restarting anything:
docker exec -w /etc/caddy caddy caddy reload
[SCREENSHOT: docker ps showing both caddy and couchdb containers running]
The bugs (the actual story)
Bug 1: "I can't create files in my own folder"
I ran sudo chown 5984:5984 on the CouchDB folders so the container could write to them, and then my own user couldn't create local.ini inside. The fix was to let my user own the config folder and leave only the data folder owned by UID 5984.
Bug 2: Zed's "rename failed, permission denied"
My editor tried to move a stray local.ini into the config folder and failed with a permission error. The real file was already in place, so the stray copy just needed deleting.
Bug 3: CouchDB crash-looping with empty logs
This was the most confusing one. docker ps showed the container as "Restarting", and docker logs printed nothing at all. Silent crashes like this usually mean the container's entrypoint script died before the app started.
What I found out:
- CouchDB's entrypoint tries to fix permissions on
/opt/couchdbat startup. - My
local.iniwas owned by my user (UID 1001) and mounted read-only (:ro). - The entrypoint couldn't change it, so it exited quietly.
The fix:
sed -i 's|10-livesync.ini:ro|10-livesync.ini|' docker-compose.yml
sudo chown 5984:5984 couchdb-config/local.ini
sudo chown -R 5984:5984 couchdb-data
docker compose down && docker compose up -d
After that, CouchDB came up and logged "Time to relax."
[SCREENSHOT: the "Apache CouchDB has started. Time to relax." log line]
A useful debugging trick from this: run the container in the foreground with docker compose run --rm --no-deps couchdb, or bypass the entrypoint with --entrypoint "" to inspect what the container actually sees.
Bug 4: System databases failing to create
The logs also showed errors like "Request to create N=3 DB but only 1 node(s)". CouchDB was trying to make three replicas of its system databases on a one-node setup. I verified single_node was applied and created the system databases manually:
docker exec couchdb sh -c 'curl -s -u "$COUCHDB_USER:$COUCHDB_PASSWORD" localhost:5984/_node/_local/_config/couchdb/single_node'
docker exec couchdb sh -c 'for d in _users _replicator _global_changes; do curl -s -u "$COUCHDB_USER:$COUCHDB_PASSWORD" -X PUT "localhost:5984/$d?n=1"; echo; done'
Verifying the whole stack
set -a; . ./.env; set +a
curl -s -u "$COUCHDB_USER:$COUCHDB_PASSWORD" https://notes.yourname.duckdns.org/
curl -s -u "$COUCHDB_USER:$COUCHDB_PASSWORD" -X PUT https://notes.yourname.duckdns.org/obsidian
First one returns a CouchDB welcome JSON, the second returns {"ok":true}. Caddy fetched the HTTPS certificate on its own.
[SCREENSHOT: terminal showing the welcome JSON and {"ok":true}]
Configuring the Obsidian side
Windows (first device)
- Settings → Community plugins → install Self-hosted LiveSync.
- In the wizard, choose "I am setting this up for the first time".
- Choose "Configure a remote manually" and select CouchDB.
- Enter:
- URI:
https://notes.yourname.duckdns.org - Username and password from the
.env - Database name:
obsidian
- URI:
- Enable end-to-end encryption, set a strong passphrase, and store it in a password manager. The passphrase isn't checked until the first sync, and there's no recovery if you lose it.
- Choose Generate a random ID key and keep the V2 (AES-256-GCM) algorithm.
- Back up the vault, then let the wizard rebuild and upload everything. Because this is a brand-new server, nothing can be overwritten.
- For the storage warning, I picked 2 GB.
[SCREENSHOT: LiveSync setup wizard, remote type screen] [SCREENSHOT: LiveSync setup wizard, encryption settings screen]
Then I generated a setup URI (command: "Copy settings as a new setup URI") to move the config to my phone. It's an obsidian://setuplivesync?... string, protected by a passphrase. I chose timebound, since the URI contains server credentials.
Android (second device)
- Create a new, empty vault in Obsidian.
- Install and enable the same plugin.
- Choose "I am adding a device to an existing synchronisation setup" and paste the setup URI.
- When asked how to start, choose Fetch from remote. Never rebuild on the second device, or you'd overwrite the server with an empty vault.
[SCREENSHOT: Android Obsidian after the first successful fetch, showing the notes]
The last gotcha: nothing synced
I wrote a note on my phone. It never appeared on Windows.
Everything was configured and connected, but LiveSync mode wasn't actually enabled on either device. The wizard sets up the connection but doesn't necessarily switch on live syncing. In the plugin's Sync Settings, set the sync preset to LiveSync on both devices.
The moment I did, notes started flowing both ways within seconds.
[SCREENSHOT: Sync Settings page with LiveSync selected]
Debugging checklist for this situation:
- Check the status icon on both devices.
- Confirm that both are on the LiveSync preset.
- Run "Replicate now" on each.
- Check the log ("Show log") for errors.
Adding audio and images
Obsidian's core Audio recorder plugin does the recording, and LiveSync syncs attachments automatically:
- Settings → Core plugins → enable Audio recorder.
- Allow microphone access on Android.
- Run "Audio recorder: Start/stop recording" from the command palette.
Things to watch:
- Recordings grow the CouchDB database faster than text, since it keeps old revisions. Compact it occasionally.
- If a large file doesn't sync, raise the max file size in the plugin settings.
- On Android, keep the screen on while recording.
[SCREENSHOT: a note with an embedded audio recording playing on both devices]
What I'd do differently
- Pick the tool by requirement first. "Nothing installed on devices" would have skipped Syncthing entirely.
- Check existing firewall rules before engineering around them. The DNS-challenge plan was clever and unnecessary.
- Watch file ownership on mounted volumes. Half my bugs were UID mismatches between my user, the container user, and read-only mounts.
- Verify the sync mode, not just the connection. Connected is not the same as live.
Things I'd still like to add
- Scheduled CouchDB backups (a dump to a separate location)
- Fail2ban or rate limiting on the login
- More projects behind the same Caddy, each on its own subdomain
Quick reference
TaskCommandRestart CouchDBcd ~/livesync && docker compose restartCouchDB logsdocker logs couchdb --tail 30Caddy logsdocker logs caddy --tail 30Reload Caddy configdocker exec -w /etc/caddy caddy caddy reloadAdd a new projectAdd a block to the Caddyfile, join its container to the proxy network, reload
Total cost: $0. Total time: one evening. Total sync reliability so far: great.