Self-host Synch without Cloudflare
Run the Synch server on your own hardware with Docker Compose or plain systemd - no Cloudflare account, no third-party services required.
If you’d rather not use Cloudflare at all, Synch’s server also runs as a plain Node.js process. This guide covers running it on your own hardware - a homelab NAS, a small VPS, an Incus/LXC container, anywhere you can run a long-lived process and expose a port - with either Docker Compose or systemd.
Data is stored entirely on disk: one SQLite file per vault, plus a small app database for accounts and vault metadata. There’s no D1, no Durable Objects, no R2 - just files in a directory you control.
If you’d rather deploy to a free Cloudflare account instead, see the Cloudflare self-hosting guide.
Before you deploy
Either way, you’ll need a way to reach the server from your Obsidian devices - either on your local network, or over the internet if you want to sync away from home (put it behind a reverse proxy with TLS in that case; the server itself only speaks plain HTTP).
Deploy with Docker Compose
Docker and Docker Compose are required. The prebuilt image supports linux/amd64 and linux/arm64; you do not need Git, Node.js, or a local build.
-
Create a new deployment directory:
mkdir synch-server cd synch-server -
Download the Compose configuration and example environment file:
curl -fsSL https://raw.githubusercontent.com/hjinco/synch/main/apps/api/docker-compose.image.yml -o docker-compose.yml curl -fsSL https://raw.githubusercontent.com/hjinco/synch/main/apps/api/.env.example -o .env -
Edit
.envand fill in:-
PUBLIC_URL- the address clients will reach this server at (e.g.http://192.168.1.50:8787on your LAN, orhttps://synch.your-domain.examplebehind a reverse proxy). This must match exactly, including scheme and port - it’s used to validate incoming request origins. -
BETTER_AUTH_SECRETandSYNC_TOKEN_SECRET- two independent random secrets. Generate each with:openssl rand -hex 32 -
AUTH_ALLOWED_EMAILS(required, unless you disable password sign-in entirely - see Single sign-on (OIDC) below) - a comma-separated list of the exact email addresses allowed to create accounts:AUTH_ALLOWED_EMAILS=you@example.com,family@example.comMatching ignores letter case and surrounding spaces. This setting only controls new accounts, so existing users can still sign in after their address is removed from the list.
-
OIDC_DISCOVERY_URL,OIDC_CLIENT_ID,OIDC_CLIENT_SECRET(optional) - enable single sign-on. See Single sign-on (OIDC) below.
-
-
Start the server:
docker compose pull docker compose up -d
Vault and blob data persist in the synch-data Docker volume across restarts and upgrades. To move to a new host, copy that volume along with your .env file.
latest follows successfully tested main builds. To pin a build, set SYNCH_IMAGE=ghcr.io/hjinco/synch-api:sha-<full-commit-SHA> in .env, or use an image digest. Pulling will not advance a pinned image; change the pin to upgrade.
Build from source (existing method)
To customize the server or keep building locally, use the original Compose file in the repository:
git clone https://github.com/hjinco/synch.git
cd synch/apps/api
cp .env.example .env
Edit .env as described above, then run docker compose up -d --build. Existing installations can continue using the same commands.
To switch an existing source installation to the image, run the following from synch/apps/api. Keep the same .env, Compose project name (including any -p or COMPOSE_PROJECT_NAME override), and volume. Do not run down -v, which deletes the data volume.
curl -fsSL https://raw.githubusercontent.com/hjinco/synch/main/apps/api/docker-compose.image.yml -o docker-compose.image.yml
docker compose -f docker-compose.image.yml pull
docker compose -f docker-compose.image.yml up -d
For all subsequent Compose commands in this directory, including upgrades and restarts, keep using -f docker-compose.image.yml.
Blob storage
By default, encrypted file contents are stored on disk inside the same data volume. If you’d rather use an S3-compatible bucket (AWS S3, MinIO, R2, etc.), uncomment and fill in the BLOB_STORAGE=s3 block in .env before starting the container.
Version history retention
Set VERSION_HISTORY_RETENTION_DAYS in .env to retain newly captured file versions for longer:
VERSION_HISTORY_RETENTION_DAYS=30
The default is 1 day. Values must be whole numbers from 1 to 36500; for example, 30 or 90. Invalid values prevent server startup. This setting is available only for self-hosted Node servers, including Docker and systemd deployments. It does not apply to Cloudflare deployments or the managed Synch service.
After editing .env, run docker compose up -d --force-recreate or restart your systemd service. The setting applies to all vaults, including existing ones: each vault picks up the policy when first accessed after restart. Newly captured history uses the new duration. Existing history keeps its original expiry date, whether you increase or decrease the setting; extending retention cannot recover history that has already expired or been deleted.
Longer retention keeps more encrypted historical file data on disk or in S3, increasing storage usage and potentially storage costs. Current files are not deleted when their history expires. Keep independent backups for disaster recovery.
Single sign-on (OIDC)
Synch can authenticate through any standards-compliant OpenID Connect provider - Keycloak, Authentik, Authelia, Zitadel, Dex, Okta, Entra ID, Auth0, and others all work. This isn’t tied to one vendor.
Uncomment and fill in these three in .env:
OIDC_DISCOVERY_URL- your provider’s discovery document, typically ending in/.well-known/openid-configurationOIDC_CLIENT_IDOIDC_CLIENT_SECRET
These three belong together: fill in all of them, or leave all of them commented out. Setting only one or two is treated as a broken configuration, not a disabled feature - the server refuses to start until the missing value is filled in, rather than quietly running without OIDC. Keep OIDC_CLIENT_SECRET in .env, which is not committed to version control, and never move it into a file that is.
Whatever provider you use, register this exact redirect URI with it:
{PUBLIC_URL}/api/auth/callback/oidc
using the PUBLIC_URL you set above - for example https://synch.your-domain.example/api/auth/callback/oidc. Getting this path wrong is the single most common way to lose an hour on OIDC setup; most providers call it a “redirect URI” or “callback URL” on their own client configuration screen.
Optional variables, also in .env:
OIDC_PROVIDER_NAME- label shown on the sign-in button. Defaults toSingle sign-on.OIDC_SCOPES- comma-separated scopes to request. Defaults toopenid,profile,email.OIDC_ACCOUNT_ISSUER- overrides the issuer identity used to scope linked accounts. Defaults to the full issuer returned by discovery, including any tenant or realm path. Normally leave this unset; assigning the same override to different issuers can confuse their accounts.
If upgrading from the first OIDC implementation, stored account issuers may contain only the discovery URL’s origin. Do not automatically carry that namespace to a different tenant. With the same verified email, the normal account-linking rules can attach the new full-issuer identity to the existing user. If emails have changed, review the affected accounts before migrating; do not fall back to matching subjects across issuers.
Verified email addresses
Your provider must also mark each user’s email address as verified - the email_verified claim in the ID token it issues. Synch rejects sign-ins whose email the provider hasn’t verified, the same rule it applies to Google and GitHub sign-in, and the sign-in page tells the user why. Some providers leave addresses unverified by default. Pocket ID, for example, only marks emails as verified once its EMAILS_VERIFIED setting is turned on, and that applies to addresses added or changed afterwards - so mark any users you created earlier as verified individually.
Account linking by email
When someone signs in through OIDC, Synch links that session to any existing local account with the same email address instead of creating a duplicate. This is deliberate: someone who registered with a password before OIDC was set up keeps their existing vaults after switching to single sign-on.
One consequence is worth knowing before you rely on this. Self-hosted Synch doesn’t send verification emails, so registering an address here never proves control of it - and that’s true regardless of whether your provider verifies addresses on its own side. So if password sign-up is still open, anyone could register one of your allowed addresses before its real owner ever signs in through your provider - and would then be linked to that account the moment the real owner does. Vault contents stay safe either way, since they’re encrypted on the client with a passphrase the server never sees; what’s exposed in that scenario is a session, the vault list and its metadata, the encrypted blobs, and the ability to delete or purge vaults - not the notes themselves. This is also why reusing your account password as your vault passphrase isn’t a good idea: it collapses a separation the encryption is designed to preserve.
Setting AUTH_EMAIL_PASSWORD=disabled (see below) closes this off, since no password account - and so no address to register ahead of its owner - can be created.
Turning off password sign-in
Password sign-up stays enabled by default alongside OIDC. Once you’ve confirmed OIDC sign-in works, you can require it exclusively by setting AUTH_EMAIL_PASSWORD=disabled in .env and restarting the service. At that point AUTH_ALLOWED_EMAILS is optional. If supplied, it still restricts new Google/GitHub accounts; OIDC accounts are exempt.
If your provider is unreachable
Discovery runs only when an OIDC operation needs it. Password login, Google/GitHub login, existing session checks and sync do not wait for it. The SSO button stays visible so you can retry after an outage. If initialization fails or takes more than three seconds, the OIDC request returns 503 OIDC_UNAVAILABLE.
On Node, failed initialization can retry after a two-second cooldown. The auth library does not expose cancellation for discovery, so a still-running fetch is retained instead of starting overlapping requests; a late successful response becomes usable automatically. On Cloudflare, initialization is scoped to the OIDC request. The three-second limit applies to initialization, not the subsequent token exchange. Local sign-out does not require contacting the identity provider.
Upgrading
Prebuilt image:
docker compose pull
docker compose up -d
Source build (from synch/apps/api):
git pull
docker compose up -d --build
Database migrations run automatically on startup.
Run without Docker (systemd)
The server runs as a prebuilt Node.js artifact (dist/server.mjs) - Docker is a convenience, not a requirement. This is a reasonable choice if you’re already running a VM (an Incus/LXC container, for example) and would rather not add Docker as a dependency.
On Debian/Ubuntu, install.sh automates everything below - clone the repo, then cd apps/api && sudo ./install.sh. It’s safe to re-run (e.g. after git pull) to update and restart. The manual steps:
-
Install Node.js 24 and a build toolchain (needed for
better-sqlite3’s native module if no prebuilt binary matches your VM’s architecture/libc):# Debian/Ubuntu sudo apt install -y nodejs python3 make g++ sudo corepack enable -
Clone the repository, build the Node artifact, and retain only production dependencies:
git clone https://github.com/hjinco/synch.git /opt/synch cd /opt/synch/apps/api pnpm install --frozen-lockfile --filter @synch/api... pnpm build:node pnpm install --frozen-lockfile --filter @synch/api... --prod --offline -
Copy
.env.exampleto.envand fill it in exactly as in the Docker Compose steps above. -
Install and start the example systemd unit:
sudo useradd --system --home /var/lib/synch-api --create-home synch sudo cp synch-api.service.example /etc/systemd/system/synch-api.service # edit the unit's paths/User/Group if you didn't use /opt/synch or the synch user sudo systemctl daemon-reload sudo systemctl enable --now synch-api -
Check it’s up:
curl http://localhost:8787/health sudo journalctl -u synch-api -f
Upgrading (systemd)
cd /opt/synch
git pull
cd apps/api
pnpm install --frozen-lockfile --filter @synch/api...
pnpm build:node
pnpm install --frozen-lockfile --filter @synch/api... --prod --offline
sudo systemctl restart synch-api
Binding to localhost only
By default the server listens on 0.0.0.0 (all interfaces) - Docker Compose needs this to make its port publishing work. If you’re running the systemd deployment behind a local reverse proxy (e.g. tailscale serve, nginx, Caddy) and don’t want the server directly reachable on your LAN or public interface, set HOST=127.0.0.1 in .env. The example systemd unit (and install.sh) already does this for you.
After changing it, update PUBLIC_URL to the address clients will actually connect through (your reverse proxy’s address, not 127.0.0.1) and restart the service - PUBLIC_URL is what better-auth validates incoming request origins against.
Connect Obsidian
- Open Obsidian.
- Go to Settings.
- Open Synch.
- In Self-hosted server, paste your server’s
PUBLIC_URL. Do not include a trailing/. - Click Save.
- Continue sign-in and vault setup normally.