Deploy Trilium Notes | (Just Updated) Self-Hosted Note Taking and Knowledge Base, Password and API Generated

Trilium Notes self-hosted note taking app, knowledge base with REST API

Deploy Trilium Notes | (Just Updated) Self-Hosted Note Taking and Knowledge Base, Password and API Generated

Just deployed

/home/node/trilium-data

Deploy and Host Trilium Notes on Railway

Built for an LLM agent to deploy and use. The deploy form has no fields to fill: the owner password is generated, the database is created before the public address opens, and everything sits on a volume. Trilium Notes is a self-hosted hierarchical note-taking app and personal knowledge base: nested notes, rich text and Markdown, code notes, relations, attachments, scripting and a REST API (ETAPI), a free alternative to hosted note services.

About Hosting Trilium Notes

This template runs one service, trilium: the upstream Trilium Notes (TriliumNext) v0.107.0 image, pinned by digest, through a thin wrapper, with a volume at /home/node/trilium-data that holds the SQLite database, attachments, configuration and session secret. One public domain serves the web app and the API. The listener is on Railway's injected PORT, and the healthcheck is GET /.

What the wrapper fixes. A fresh upstream Trilium has no database and no password, and the first visitor to its public address gets to create both: whoever finds the new domain first owns the instance. The wrapper creates the database and sets the owner password from the ADMIN_PASSWORD variable on a loopback-only listener, stops that server, and only then opens the public listener, so there is never a moment when a stranger can claim it. It also hands the root-owned volume to the app user, trusts Railway's proxy so client addresses and HTTPS are read correctly, and adds an IPv6 front on the same port for Railway's private network.

Using it. Open the domain and enter ADMIN_PASSWORD to use the web app. For an agent, POST /etapi/auth/login with the password returns an ETAPI token; send it in the Authorization header to create, read, update and delete notes, branches, attributes and attachments under /etapi. The owner password is set once, on first boot: changing ADMIN_PASSWORD afterwards does not change it, and a request to set a new password on a running instance is ignored. To change it, use Options in the web app. Keep the volume: it is the whole instance.

Agent contract

  • Public URL: https://RAILWAY_PUBLIC_DOMAIN (the generated domain of the trilium service); the API is under /etapi
  • Private URL: http://trilium.railway.internal:8080 (IPv4 and IPv6)
  • Credentials: the variable ADMIN_PASSWORD on the trilium service is the owner password for the web login and for POST /etapi/auth/login
  • Auth: POST /etapi/auth/login with {"password": "ADMIN_PASSWORD value"} returns {"authToken": "..."}; send it as Authorization: AUTHTOKEN on every other /etapi/* call. A write with no token answers 401, a write with a wrong token answers 401, a wrong password answers 401, and the database cannot be re-created or the password replaced by a stranger (/api/setup/new-document answers 401).
  • Health: GET /api/health-check returns 200 with {"status":"ok"}
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, ADMIN_PASSWORD (variables of the trilium service); also curl, date, sed. Creates a throwaway note and removes it again.
R="https://$RAILWAY_PUBLIC_DOMAIN"; J="Content-Type: application/json"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/api/health-check")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/api/health-check"
# log in with the generated password: the response carries an ETAPI token
TOK=$(curl -s -X POST -H "$J" -d "{\"password\":\"$ADMIN_PASSWORD\"}" "$R/etapi/auth/login" | sed 's/.*"authToken":"\([^"]*\)".*/\1/')
curl -s -o /dev/null -w "login: %{http_code}\n" -X POST -H "$J" -d "{\"password\":\"$ADMIN_PASSWORD\"}" "$R/etapi/auth/login"
# read with the token
curl -s -o /dev/null -w "read app-info: %{http_code}\n" -H "Authorization: $TOK" "$R/etapi/app-info"
# write with the token: create a throwaway note, read it back, remove it
N="agent-$(date +%s)"
ID=$(curl -s -X POST -H "$J" -H "Authorization: $TOK" -d "{\"parentNoteId\":\"root\",\"title\":\"$N\",\"type\":\"text\",\"content\":\"hello\"}" "$R/etapi/create-note" | sed 's/.*"noteId":"\([^"]*\)".*/\1/')
curl -s -o /dev/null -w "write note: %{http_code}\n" -H "Authorization: $TOK" "$R/etapi/notes/$ID"
if curl -s -H "Authorization: $TOK" "$R/etapi/notes/$ID/content" | grep -q hello; then echo "read back: found"; else echo "read back: MISSING"; fi
curl -s -o /dev/null -w "delete note: %{http_code}\n" -X DELETE -H "Authorization: $TOK" "$R/etapi/notes/$ID"
curl -s -o /dev/null -w "after delete: %{http_code}\n" -H "Authorization: $TOK" "$R/etapi/notes/$ID"
# refusals: no token, wrong token, wrong password, public sign-up (database re-creation by a stranger), password takeover
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST -H "$J" -d '{"parentNoteId":"root","title":"intruder","type":"text","content":"x"}' "$R/etapi/create-note"
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -X POST -H "$J" -H "Authorization: not-a-token" -d '{"parentNoteId":"root","title":"intruder","type":"text","content":"x"}' "$R/etapi/create-note"
curl -s -o /dev/null -w "login wrong password: %{http_code}\n" -X POST -H "$J" -d '{"password":"not-the-password"}' "$R/etapi/auth/login"
curl -s -o /dev/null -w "public signup: %{http_code}\n" -X POST -H "$J" -d '{"locale":"en"}' "$R/api/setup/new-document"
curl -s -o /dev/null -X POST -H "$J" -d '{"password1":"takeover-attempt","password2":"takeover-attempt"}' "$R/set-password"
curl -s -o /dev/null -w "takeover password login: %{http_code}\n" -X POST -H "$J" -d '{"password":"takeover-attempt"}' "$R/etapi/auth/login"

Expected output against a fresh deploy (measured on a Railway deploy of the published template):

health: 200
login: 201
read app-info: 200
write note: 200
read back: found
delete note: 204
after delete: 404
write without key: 401
write wrong key: 401
login wrong password: 401
public signup: 401
takeover password login: 401

The refusals are the contract: write without key: 401, write wrong key: 401, login wrong password: 401, public signup: 401 and takeover password login: 401 (a stranger can neither create the database nor choose the password). The first seven lines show the owner password yields a token that can read, write and delete.

Why Deploy Trilium Notes on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Trilium Notes on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

  • Agent-ready - no deployer fields, a contract block, and one script that proves the instance is healthy, the password yields a token that can read, write and delete, and strangers can write nothing.
  • Nobody can claim it first - the database and owner password exist before the public address opens.
  • Data survives redeploys - the database, attachments and configuration live on a volume.
  • Pinned - the upstream image is pinned by digest and the wrapper by tag and digest.

Common Use Cases

  • Personal knowledge base - hierarchical notes, wiki-style links and attributes on your own server.
  • Notes for an AI agent - an agent reads and writes notes over the ETAPI with the generated password.
  • Team documentation and research - a private note tree with attachments and code notes.
  • Web clipping and journaling - collect pages, drafts and daily notes in one searchable database.

Dependencies for Trilium Notes Hosting

  • The trilium service with its volume, created by the template. A custom domain is optional; the wrapper does not need the domain name.

Deployment Dependencies


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
NEW
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0