Skip to content

Build your personal knowledge base with Trilium Notes

feat(server): print the addresses the server listens on

Elian Doran84814f3a7465
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index 61e079408f..efb1427896 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -8,11 +8,11 @@
"_help_7iwde4lsKc6O": "<aside class=\"admonition note\"><p>Automatic startup and better integration with the system tray was introduced in v0.104.0. Versions prior to that only have the system tray option which could be found in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Others</em>.</p></aside><h2>Tray icon</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:332/71;\" src=\"{{helpAssets}}/User%20Guide/Installation%20%26%20Setup/Desktop%20Installation/Tray%20icon%20%26%20automatic%20startup_image.png\" width=\"332\" height=\"71\"></figure><p>The desktop application has native integration with the system tray on all operating systems.</p><p>The tray icon is enabled by default, but it can be toggled from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Desktop</em>.</p><p>The tray icon has the following functionality:</p><ul><li>When clicked, the last window is hidden (minimized to the tray icon). Clicking it again will reveal that window.</li><li>Right clicking reveals the following options:<ul><li>Each window can be individually shown or hidden, identified by their active note.</li><li>New windows can be opened.</li><li>A new note can be created directly, which will be created in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>&nbsp;(or&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;if an inbox is not available).</li><li>Today's day note can be opened.</li><li>Bookmarks and recent notes are displayed in a sub-menu and clicking them navigates to that note.</li><li>Quitting the application.</li></ul></li></ul><h3>Closing to system tray</h3><p>This is an option which is not enabled by default and it allows a specific behavior: instead of exiting the application when the last window has been closed, the last window is instead hidden with the tray icon remaining available.</p><p>This option requires the tray icon to be enabled, otherwise it has no effect.</p><h2>Automatic startup</h2><p>Two options control the automatic startup functionality in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Startup</em>:</p><ul><li>When <em>Launch on startup</em> is enabled, the application will automatically start up when logging into the current user.<ul><li>Note that on Linux support depends on the desktop environment. Feel free to <a href=\"#root/_help_wy8So3yZZlH9\">report</a> any issues.</li></ul></li><li>If <em>Start minimized to tray</em> is also enabled, the application will start up in the background and can be revealed from the tray icon.<ul><li>This only applies if <em>Launch on startup</em> is enabled, manual starts are not impacted by this option.</li></ul></li></ul><h3>Linux: custom launch command for packagers</h3><p>On Linux, <em>Launch on startup</em> writes a <code>trilium.desktop</code> entry to the user's autostart directory (<code>$XDG_CONFIG_HOME/autostart</code>, usually <code>~/.config/autostart</code>). Its <code>Exec</code> line points to the AppImage when running from one, or to the running executable otherwise.</p><p>Distribution packages that run Trilium on a system-wide Electron (for example <code>electron /usr/lib/trilium/app.asar</code>) cannot rely on the running executable, since it is the bare Electron binary, which starts without Trilium. Such packages can set the <code>TRILIUM_LAUNCH_EXEC</code> environment variable, typically in their wrapper script, to the full command that starts Trilium:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_LAUNCH_EXEC='electron \"/usr/lib/trilium/app.asar\"'</code></pre><p>The value is written to the <code>Exec</code> line as-is, so any paths containing spaces must already be quoted. When <em>Start minimized to tray</em> is enabled, <code>--start-hidden</code> is appended to it. <code>TRILIUM_LAUNCH_EXEC</code> takes precedence over both the AppImage path and the running executable.</p>",
"_help_hvRfsDr591WP": "<h2>Trilium only shows a blank window</h2><p>Trilium uses Electron which is based on Chromium (the open-source alternative to Google Chrome); in order to improve performance it makes use of <em>GPU acceleration</em>. In some cases, a GPU incompatibility (especially on older models of integrated graphics) can cause nothing to render at all, resulting in a blank window.&nbsp;</p><p>To bypass this, try running Trilium with the following command line argument:</p><pre><code class=\"language-text-x-trilium-auto\">trilium --disable-gpu</code></pre><p>If that doesn't work, try the following commands as well:</p><ul><li><code>trilium --disable-gpu-compositing</code></li><li><code>ELECTRON_OZONE_PLATFORM_HINT=x11 trilium</code> (this one forces the rendering to X11 on Wayland)</li></ul><p>If Trilium renders fine after this, Trilium offers a built-in option to disable GPU acceleration: go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Appearance</em>, look for the <em>Performance</em> section and then uncheck <em>Hardware acceleration (GPU)</em>.</p>",
"_help_WOcw2SLH6tbX": "<p>This guide outlines the steps to install Trilium on your own server. You might consider this option if you want to set up <a href=\"#root/_help_cbkrhQjrkKrh\">synchronization</a> or use Trilium in a browser - accessible from anywhere.</p><h2>Installation Options</h2><p>There are several ways to install Trilium on a server, each with its own advantages:</p><ul><li><strong>Recommended</strong>: <a href=\"#root/_help_rWX5eY045zbE\">Docker Installation</a> - Available for <strong>AMD64</strong> and <strong>ARM</strong> architectures.</li><li><a href=\"#root/_help_3tW6mORuTHnB\">Packaged Server Installation</a></li><li><a href=\"https://www.pikapods.com/pods?run=trilium-next\">PikaPods managed hosting</a></li><li><a href=\"#root/_help_J1Bb6lVlwU5T\">Manual Installation</a></li><li><a href=\"#root/_help_DCmT6e7clMoP\">Kubernetes</a></li><li><a href=\"https://www.cloudron.io/store/com.github.trilium.cloudronapp.html\">Cloudron</a></li><li><a href=\"https://homelabos.com/docs/software/trilium/\">HomelabOS</a></li><li><a href=\"#root/_help_moVgBcoxE3EK\">NixOS Module</a></li></ul><p>The server installation includes both web and <a href=\"#root/_help_RDslemsQ6gCp\">mobile frontends</a>.</p><h2>Configuration</h2><p>After setting up your server installation, you may want to configure settings such as the port or enable <a href=\"#root/_help_l2VkvOwUNfZj\">TLS</a>. Configuration is managed via the Trilium <code>config.ini</code> file, which is located in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> by default. To begin customizing your setup, copy the provided <code>config-sample.ini</code> file with default values to <code>config.ini</code>.</p><p>You can also review the <a href=\"#root/_help_Gzjqa934BdH4\">configuration</a> file to provide all <code>config.ini</code> values as environment variables instead.</p><h3>Config Location</h3><p>By default, <code>config.ini</code>, the <a href=\"#root/_help_wX4HbRucYSDD\">database</a>, and other important Trilium data files are stored in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a>. If you prefer a different location, you can change it by setting the <code>TRILIUM_DATA_DIR</code> environment variable:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data</code></pre><h3>Disabling Authentication</h3><p>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_0hzsNCP31IAB\">Authentication</a>.</p><h2>Reverse Proxy Setup</h2><p>To configure a reverse proxy for Trilium, you can use either <strong>nginx</strong> or <strong>Apache</strong>. You can also check out the documentation stored in the Reverse proxy folder.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">nginx</p><div class=\"trilium-tab-panel\"><p>Add the following configuration to your <code>nginx</code> setup to proxy requests to Trilium:</p><pre><code class=\"language-text-x-trilium-auto\">location /trilium/ {\n proxy_pass http://127.0.0.1:8080/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection 'upgrade';\n proxy_set_header Host $host;\n proxy_cache_bypass $http_upgrade;\n}</code></pre><p>To avoid limiting the size of payloads, include this in the <code>server {}</code> block:</p><pre><code class=\"language-text-x-trilium-auto\"># Set to 0 for unlimited. Default is 1M.\nclient_max_body_size 0;</code></pre></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Apache</p><div class=\"trilium-tab-panel\"><p>For an Apache setup, refer to the&nbsp;<a class=\"reference-link\" href=\"#root/_help_fDLvzOx29Pfg\">Apache using Docker</a>&nbsp;guide.</p></div></section></div>",
- "_help_3tW6mORuTHnB": "<p>This is essentially Trilium sources + node modules + node.js runtime packaged into one 7z file.</p><h2>Steps</h2><ul><li>SSH into your server</li><li>use <code>wget</code> (or <code>curl</code>) to download latest <code>TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code> (copy link from <a href=\"https://github.com/TriliumNext/Trilium/releases\">release page</a>, notice <code>-Server</code> suffix) on your server.</li><li>unpack the archive, e.g. using <code>tar -xf -d TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code></li><li><code>cd trilium-linux-x64-server</code></li><li><code>./trilium.sh</code></li><li>you can open the browser and open http://[your-server-hostname]:8080 and you should see Trilium initialization page</li></ul><p>The problem with above steps is that once you close the SSH connection, the Trilium process is terminated. To avoid that, you have two options:</p><ul><li>Kill it (with e.g. <kbd>Ctrl</kbd> + <kbd>C</kbd>) and run again like this: <code>nohup ./trilium.sh &amp;</code>. (nohup keeps the process running in the background, <code>&amp;</code> runs it in the background)</li><li>Configure systemd to automatically run Trilium in the background on every boot</li></ul><h2>Configure Trilium to auto-run on boot with systemd</h2><ul><li>After downloading, extract and move Trilium:</li></ul><pre><code class=\"language-text-x-trilium-auto\">tar -xvf TriliumNotes-Server-[VERSION]-linux-x64.tar.xz\nsudo mv trilium-linux-x64-server /opt/trilium</code></pre><ul><li>Create the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo nano /etc/systemd/system/trilium.service</code></pre><ul><li>Paste this into the file (replace the user and group as needed):</li></ul><pre><code class=\"language-text-x-trilium-auto\">[Unit]\nDescription=Trilium Daemon\nAfter=syslog.target network.target\n\n[Service]\nUser=xxx\nGroup=xxx\nType=simple\nExecStart=/opt/trilium/trilium.sh\nWorkingDirectory=/opt/trilium/\n\nTimeoutStopSec=20\n# KillMode=process leads to error, according to https://www.freedesktop.org/software/systemd/man/systemd.kill.html\nRestart=always\n\n[Install]\nWantedBy=multi-user.target</code></pre><ul><li>Save the file (CTRL-S) and exit (CTRL-X)</li><li>Enable and launch the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo systemctl enable --now -q trilium</code></pre><ul><li>You can now open a browser to http://[your-server-hostname]:8080 and you should see the Trilium initialization page.</li></ul><h2>Simple auto-update for Server</h2><p>The script is available in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZNAjFcxqHr9V\">Simple auto-update for server</a>.</p><ul><li><p>Run as the same User Trilium runs.</p><ul><li>If you run as <code>root</code> please remove <code>sudo</code> from the commands.</li></ul></li><li><p>Requires <code>jq</code>:</p><pre><code class=\"language-text-x-sh\">apt install jq</code></pre></li></ul><p>It will stop the service above, overwrite everything (expecting no <code>config.ini</code>), and start service. It also creates a version file in the Trilium directory so it updates only with a newer version.</p><h2>Common issues</h2><h3>Outdated glibc</h3><pre><code class=\"language-text-x-trilium-auto\">Error: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/www/virtual/.../node_modules/@mlink/scrypt/build/Release/scrypt.node)\n at Object.Module._extensions..node (module.js:681:18)\n at Module.load (module.js:565:32)\n at tryModuleLoad (module.js:505:12)</code></pre><p>If you get an error like this, you need to either upgrade your glibc (typically by upgrading to up-to-date distribution version) or use some other <a href=\"#root/_help_WOcw2SLH6tbX\">server installation</a> method.</p><h2>TLS</h2><p>Don't forget to <a href=\"#root/_help_l2VkvOwUNfZj\">configure TLS</a>, which is required for secure usage!</p>",
+ "_help_3tW6mORuTHnB": "<p>This is essentially Trilium sources + node modules + node.js runtime packaged into one 7z file.</p><h2>Steps</h2><ul><li>SSH into your server</li><li>use <code>wget</code> (or <code>curl</code>) to download latest <code>TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code> (copy link from <a href=\"https://github.com/TriliumNext/Trilium/releases\">release page</a>, notice <code>-Server</code> suffix) on your server.</li><li>unpack the archive, e.g. using <code>tar -xf -d TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code></li><li><code>cd trilium-linux-x64-server</code></li><li><code>./trilium.sh</code></li><li>you can open the browser and open http://[your-server-hostname]:8080 and you should see Trilium initialization page</li><li>the console lists the addresses the server can be reached on, so you can also copy one from there</li></ul><p>The problem with above steps is that once you close the SSH connection, the Trilium process is terminated. To avoid that, you have two options:</p><ul><li>Kill it (with e.g. <kbd>Ctrl</kbd> + <kbd>C</kbd>) and run again like this: <code>nohup ./trilium.sh &amp;</code>. (nohup keeps the process running in the background, <code>&amp;</code> runs it in the background)</li><li>Configure systemd to automatically run Trilium in the background on every boot</li></ul><h2>Configure Trilium to auto-run on boot with systemd</h2><ul><li>After downloading, extract and move Trilium:</li></ul><pre><code class=\"language-text-x-trilium-auto\">tar -xvf TriliumNotes-Server-[VERSION]-linux-x64.tar.xz\nsudo mv trilium-linux-x64-server /opt/trilium</code></pre><ul><li>Create the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo nano /etc/systemd/system/trilium.service</code></pre><ul><li>Paste this into the file (replace the user and group as needed):</li></ul><pre><code class=\"language-text-x-trilium-auto\">[Unit]\nDescription=Trilium Daemon\nAfter=syslog.target network.target\n\n[Service]\nUser=xxx\nGroup=xxx\nType=simple\nExecStart=/opt/trilium/trilium.sh\nWorkingDirectory=/opt/trilium/\n\nTimeoutStopSec=20\n# KillMode=process leads to error, according to https://www.freedesktop.org/software/systemd/man/systemd.kill.html\nRestart=always\n\n[Install]\nWantedBy=multi-user.target</code></pre><ul><li>Save the file (CTRL-S) and exit (CTRL-X)</li><li>Enable and launch the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo systemctl enable --now -q trilium</code></pre><ul><li>You can now open a browser to http://[your-server-hostname]:8080 and you should see the Trilium initialization page.</li></ul><h2>Simple auto-update for Server</h2><p>The script is available in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZNAjFcxqHr9V\">Simple auto-update for server</a>.</p><ul><li><p>Run as the same User Trilium runs.</p><ul><li>If you run as <code>root</code> please remove <code>sudo</code> from the commands.</li></ul></li><li><p>Requires <code>jq</code>:</p><pre><code class=\"language-text-x-sh\">apt install jq</code></pre></li></ul><p>It will stop the service above, overwrite everything (expecting no <code>config.ini</code>), and start service. It also creates a version file in the Trilium directory so it updates only with a newer version.</p><h2>Common issues</h2><h3>Outdated glibc</h3><pre><code class=\"language-text-x-trilium-auto\">Error: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/www/virtual/.../node_modules/@mlink/scrypt/build/Release/scrypt.node)\n at Object.Module._extensions..node (module.js:681:18)\n at Module.load (module.js:565:32)\n at tryModuleLoad (module.js:505:12)</code></pre><p>If you get an error like this, you need to either upgrade your glibc (typically by upgrading to up-to-date distribution version) or use some other <a href=\"#root/_help_WOcw2SLH6tbX\">server installation</a> method.</p><h2>TLS</h2><p>Don't forget to <a href=\"#root/_help_l2VkvOwUNfZj\">configure TLS</a>, which is required for secure usage!</p>",
"_help_ZNAjFcxqHr9V": "#!/bin/bash\n\n# Configuration\nREPO=\"TriliumNext/Trilium\"\nPATTERN=\"TriliumNotes-Server-.*-linux-x64.tar.xz\"\nDOWNLOAD_DIR=\"/var/tmp/trilium_download\"\nOUTPUT_DIR=\"/opt/trilium\"\nSERVICE_NAME=\"trilium\"\nVERSION_FILE=\"$OUTPUT_DIR/version.txt\"\n\n# Ensure dependencies are installed\ncommand -v curl >/dev/null 2>&1 || { echo \"Error: curl is required\"; exit 1; }\ncommand -v jq >/dev/null 2>&1 || { echo \"Error: jq is required\"; exit 1; }\ncommand -v tar >/dev/null 2>&1 || { echo \"Error: tar is required\"; exit 1; }\n\n# Create download directory\nmkdir -p \"$DOWNLOAD_DIR\" || { echo \"Error: Cannot create $DOWNLOAD_DIR\"; exit 1; }\n\n# Get the latest release version\nLATEST_VERSION=$(curl -sL https://api.github.com/repos/$REPO/releases/latest | jq -r '.tag_name')\nif [ -z \"$LATEST_VERSION\" ]; then\n echo \"Error: Could not fetch latest release version\"\n exit 1\nfi\n\n# Check current installed version (from version.txt or existing tarball)\nCURRENT_VERSION=\"\"\nif [ -f \"$VERSION_FILE\" ]; then\n CURRENT_VERSION=$(cat \"$VERSION_FILE\")\nelif [ -f \"$DOWNLOAD_DIR/TriliumNotes-Server-$LATEST_VERSION-linux-x64.tar.xz\" ]; then\n CURRENT_VERSION=\"$LATEST_VERSION\"\nfi\n\n# Compare versions\nif [ \"$CURRENT_VERSION\" = \"$LATEST_VERSION\" ]; then\n echo \"Latest version ($LATEST_VERSION) is already installed\"\n exit 0\nfi\n\n# Download the latest release\nLATEST_URL=$(curl -sL https://api.github.com/repos/$REPO/releases/latest | jq -r \".assets[] | select(.name | test(\\\"$PATTERN\\\")) | .browser_download_url\")\nif [ -z \"$LATEST_URL\" ]; then\n echo \"Error: No asset found matching pattern '$PATTERN'\"\n exit 1\nfi\n\nFILE_NAME=$(basename \"$LATEST_URL\")\nFILE_PATH=\"$DOWNLOAD_DIR/$FILE_NAME\"\n\n# Download if not already present\nif [ -f \"$FILE_PATH\" ]; then\n echo \"Latest release $FILE_NAME already downloaded\"\nelse\n curl -LO --output-dir \"$DOWNLOAD_DIR\" \"$LATEST_URL\" || { echo \"Error: Download failed\"; exit 1; }\n echo \"Downloaded $FILE_NAME to $DOWNLOAD_DIR\"\nfi\n\n# Extract the tarball\nEXTRACT_DIR=\"$DOWNLOAD_DIR/extracted\"\nmkdir -p \"$EXTRACT_DIR\"\ntar -xJf \"$FILE_PATH\" -C \"$EXTRACT_DIR\" || { echo \"Error: Extraction failed\"; exit 1; }\n\n# Find the extracted directory (e.g., TriliumNotes-Server-0.97.2-linux-x64)\nINNER_DIR=$(find \"$EXTRACT_DIR\" -maxdepth 1 -type d -name \"TriliumNotes-Server-*-linux-x64\" | head -n 1)\nif [ -z \"$INNER_DIR\" ]; then\n echo \"Error: Could not find extracted directory matching TriliumNotes-Server-*-linux-x64\"\n exit 1\nfi\n\n# Stop the trilium-server service\nif systemctl is-active --quiet \"$SERVICE_NAME\"; then\n echo \"Stopping $SERVICE_NAME service...\"\n sudo systemctl stop \"$SERVICE_NAME\" || { echo \"Error: Failed to stop $SERVICE_NAME\"; exit 1; }\nfi\n\n# Copy contents to /opt/trilium, overwriting existing files\necho \"Copying contents from $INNER_DIR to $OUTPUT_DIR...\"\nsudo mkdir -p \"$OUTPUT_DIR\"\nsudo cp -r \"$INNER_DIR\"/* \"$OUTPUT_DIR\"/ || { echo \"Error: Copy failed\"; exit 1; }\necho \"$LATEST_VERSION\" | sudo tee \"$VERSION_FILE\" >/dev/null\necho \"Files copied to $OUTPUT_DIR\"\n\n# Start the trilium-server service\necho \"Starting $SERVICE_NAME service...\"\nsudo systemctl start \"$SERVICE_NAME\" || { echo \"Error: Failed to start $SERVICE_NAME\"; exit 1; }\n\n# Clean up\nrm -rf \"$EXTRACT_DIR\"\necho \"Cleanup complete. Trilium updated to $LATEST_VERSION.\"",
"_help_rWX5eY045zbE": "<p>Official docker images are published on docker hub for <strong>AMD64</strong>, <strong>ARMv7</strong> and <strong>ARM64/v8</strong>: <a href=\"https://hub.docker.com/r/triliumnext/trilium/\">https://hub.docker.com/r/triliumnext/trilium/</a></p><h2>Prerequisites</h2><p>Ensure Docker is installed on your system.</p><p>If you need help installing Docker, reference the <a href=\"https://docs.docker.com/engine/install/\">Docker Installation Docs</a></p><p>By default, the container starts as root, prepares the data directory and then runs Trilium as an unprivileged user. It can also run entirely without root, as described in <em>Running as a non-root user</em> below.</p><aside class=\"admonition warning\"><p>If you're using a SMB/CIFS share or folder as your Trilium data directory, <a href=\"https://github.com/TriliumNext/Notes/issues/415#issuecomment-2344824400\">you'll need</a> to add the mount options of <code>nobrl</code> and <code>noperm</code> when mounting your SMB share.</p></aside><h2>Running with Docker Compose</h2><h3>Grab the latest docker-compose.yml:</h3><pre><code class=\"language-text-x-trilium-auto\">wget https://raw.githubusercontent.com/TriliumNext/Trilium/master/docker-compose.yml</code></pre><p>Optionally, edit the <code>docker-compose.yml</code> file to configure the container settings prior to starting it. Unless configured otherwise, the data directory will be <code>trilium-data</code> next to <code>docker-compose.yml</code> and the container will be accessible at port 8080.</p><p>To keep the data somewhere else, edit the <code>volumes</code> entry in <code>docker-compose.yml</code> and change the host path before the colon (for example <code>- /srv/trilium-data:/home/node/trilium-data</code>). Leave the path after the colon unchanged.</p><h3>Start the container:</h3><p>Run the following command to start the container in the background:</p><pre><code class=\"language-text-x-trilium-auto\">docker compose up -d</code></pre><h2>Running without Docker Compose / Further Configuration</h2><h3>Pulling the Docker Image</h3><p>To pull the image, use the following command, replacing <code>[VERSION]</code> with the desired version or tag, such as <code>v0.91.6</code> or just <code>latest</code>. (See published tag names at <a href=\"https://hub.docker.com/r/triliumnext/trilium/tags\">https://hub.docker.com/r/triliumnext/trilium/tags</a>.):</p><pre><code class=\"language-text-x-trilium-auto\">docker pull triliumnext/trilium:v0.91.6</code></pre><p><strong>Warning:</strong> Avoid using the \"latest\" tag, as it may automatically upgrade your instance to a new minor version, potentially disrupting sync setups or causing other issues.</p><h3>Preparing the Data Directory</h3><p>Trilium requires a directory on the host system to store its data. This directory must be mounted into the Docker container with write permissions.</p><h3>Running the Docker Container</h3><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Local Access Only</p><div class=\"trilium-tab-panel\"><p>Run the container to make it accessible only from the localhost. This setup is suitable for testing or when using a proxy server like Nginx or Apache.</p><pre><code class=\"language-text-x-sh\">sudo docker run -t -i -p 127.0.0.1:8080:8080 \\\n\t-v ~/trilium-data:/home/node/trilium-data \\\n\ttriliumnext/trilium:[VERSION]</code></pre><ol><li>Verify the container is running using <code>docker ps</code>.</li><li>Access Trilium via a web browser at <code>127.0.0.1:8080</code>.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Local Network Access</p><div class=\"trilium-tab-panel\"><p>To make the container accessible only on your local network, first create a new Docker network:</p><pre><code class=\"language-text-x-sh\">docker network create -d macvlan -o parent=eth0 --subnet 192.168.2.0/24 --gateway 192.168.2.254 --ip-range 192.168.2.252/27 mynet</code></pre><p>Then, run the container with the network settings:</p><pre><code class=\"language-text-x-sh\">docker run --net=mynet -d -p 127.0.0.1:8080:8080 -v ~/trilium-data:/home/node/trilium-data triliumnext/trilium:-latest</code></pre><p>To set a different user ID (UID) and group ID (GID) for the saved data, use the <code>USER_UID</code> and <code>USER_GID</code> environment variables:</p><pre><code class=\"language-text-x-sh\">docker run --net=mynet -d -p 127.0.0.1:8080:8080 -e \"USER_UID=1001\" -e \"USER_GID=1001\" -v ~/trilium-data:/home/node/trilium-data triliumnext/trilium:-latest</code></pre><p>Find the local IP address using <code>docker inspect [container_name]</code> and access the service from devices on the local network.</p><pre><code class=\"language-text-x-sh\">docker ps\ndocker inspect [container_name]</code></pre></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Global Access</p><div class=\"trilium-tab-panel\"><p>To allow access from any IP address, run the container as follows:</p><pre><code class=\"language-text-x-sh\">docker run -d -p 0.0.0.0:8080:8080 \\\n\t-v ~/trilium-data:/home/node/trilium-data \\\n\ttriliumnext/trilium:[VERSION]</code></pre><p>Stop the container with <code>docker stop &lt;CONTAINER ID&gt;</code>, where the container ID is obtained from <code>docker ps</code>.</p></div></section></div><h3>Custom Data Directory</h3><p>For a custom data directory, use:</p><pre><code class=\"language-text-x-trilium-auto\">-v ~/YourOwnDirectory:/home/node/trilium-data triliumnext/trilium:[VERSION]</code></pre><p>If you want to run your instance in a non-default way, please use the volume switch as follows: <code>-v ~/YourOwnDirectory:/home/node/trilium-data triliumnext/trilium:&lt;VERSION&gt;</code>. It is important to be aware of how Docker works for volumes, with the first path being your own and the second the one to virtually bind to. <a href=\"https://docs.docker.com/storage/volumes/\">https://docs.docker.com/storage/volumes/</a> The path before the colon is the host directory, and the path after the colon is the container's path. More details can be found in the <a href=\"https://docs.docker.com/storage/volumes/\">Docker Volumes Documentation</a>.</p><h2>Reverse Proxy</h2><ol><li><a href=\"#root/_help_ud6MShXL4WpO\">Nginx</a></li><li><a href=\"#root/_help_fDLvzOx29Pfg\">Apache</a></li></ol><h3>Note on timezones</h3><p>If you are having timezone issues and you are not using docker-compose, you may need to add a <code>TZ</code> environment variable with the <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\">TZ identifier</a> of your local timezone.</p><h3>Other environment variables</h3><p>For the complete list of environment variables Trilium reads (network settings, authentication, sync, etc.), see&nbsp;<a class=\"reference-link\" href=\"#root/_help_Gzjqa934BdH4\">Configuration (config.ini or environment variables)</a>.</p><h2>Running as a non-root user</h2><p>By default, the container starts as root, gives the data directory to the <code>node</code> user (UID and GID <code>1000</code>, or the values of <code>USER_UID</code> and <code>USER_GID</code>) and then runs Trilium as that user. Some environments do not allow a container to start as root at all, for example rootless Docker or Podman, or Kubernetes with <code>runAsNonRoot</code>. Starting with v0.107.0, the same image can run entirely as a non-root user instead.</p><p>To run Trilium as a non-root user, set the user with Docker's <code>--user</code> flag:</p><pre><code class=\"language-text-x-sh\">docker run -d -p 8080:8080 --user 1000:1000 -v /srv/trilium-data:/home/node/trilium-data triliumnext/trilium:[VERSION]</code></pre><p>With Docker Compose, add <code>user:</code> to the service in <code>docker-compose.yml</code>:</p><pre><code class=\"language-text-x-yaml\">services:\n trilium:\n user: \"1000:1000\"</code></pre><p>The image also runs with a read-only root filesystem and without any capabilities, for example with <code>--read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges</code>.</p><p>Without root, the container cannot change the ownership of files, so:</p><ul><li><p>The data directory on the host must exist and belong to that user before the container starts. If the directory is missing, Docker creates it as root, and Trilium cannot write to it. For example:</p><pre><code class=\"language-text-x-sh\">mkdir -p /srv/trilium-data\nsudo chown 1000:1000 /srv/trilium-data</code></pre></li><li><p>A named volume instead of a host directory only works for UID <code>1000</code>: Docker gives a new volume the owner of the image's data directory, which is the <code>node</code> user.</p></li><li><p><code>USER_UID</code> and <code>USER_GID</code> are ignored. The user comes from <code>--user</code> or <code>user:</code> alone.</p></li></ul><p>If Trilium cannot use its data directory, it stops at startup and prints which directory or files it cannot use, who owns them, and the command that fixes it.</p><aside class=\"admonition note\"><p>An installation that ran as root leaves its files owned by UID <code>1000</code>, or by <code>USER_UID</code> if it was set. To switch it to <code>--user</code>, either use that same UID, or give the data directory to the new user first, for example with <code>sudo chown -R 1001:1001 /srv/trilium-data</code>.</p></aside>",
"_help_moVgBcoxE3EK": "<p>This page describes configuring the Trilium module included in NixOS.</p><h2>Requirements</h2><p><a href=\"https://nixos.org/\">NixOS</a> installation.</p><h2>Configuration</h2><p>Add this to your <code>configuration.nix</code>:</p><pre><code class=\"language-text-x-trilium-auto\">services.trilium-server.enable = true;\n\n# default data directory: /var/lib/trilium\n#services.trilium-server.dataDir = \"/var/lib/trilium-sync-server\";\n\n# default bind address: 127.0.0.1, port 8080\n#services.trilium-server.host = \"0.0.0.0\";\n#services.trilium-server.port = 12783;</code></pre><p>Uncomment any option you would like to change.</p><p>See the <a href=\"https://search.nixos.org/options?channel=unstable&amp;from=0&amp;size=50&amp;sort=relevance&amp;type=packages&amp;query=trilium-server\">NixOS options list</a> for more options (including nginx reverse proxy configuration).</p>",
- "_help_J1Bb6lVlwU5T": "<aside class=\"admonition warning\"><p>This page describes manually installing Trilium on your server. <strong>Note that this is a not well supported way to install Trilium, problems may appear, information laid out here is quite out of date. It is recommended to use either</strong>&nbsp;<a class=\"reference-link\" href=\"#root/_help_rWX5eY045zbE\">Docker Server Installation</a>&nbsp;<strong>or</strong>&nbsp;<a class=\"reference-link\" href=\"#root/_help_3tW6mORuTHnB\">Packaged server installation</a><strong>.</strong></p></aside><h2>Requirements</h2><p>Trilium is a node.js application. Supported (tested) version of node.js is latest 14.X.X and 16.X.X. Trilium might work with older versions as well.</p><p>You can check your node version with this command (node.js needs to be installed):</p><pre><code class=\"language-text-x-trilium-auto\">node --version</code></pre><p>If your Linux distribution has only an outdated version of node.js, you can take a look at the installation instruction on node.js website, which covers most popular distributions.</p><h3>Dependencies</h3><p>There are some dependencies required. You can see command for Debian and its derivatives (like Ubuntu) below:</p><pre><code class=\"language-text-x-trilium-auto\">sudo apt install libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev</code></pre><h2>Installation</h2><h3>Download</h3><p>You can either download source code zip/tar from <a href=\"https://github.com/TriliumNext/Trilium/releases/latest\">https://github.com/TriliumNext/Trilium/releases/latest</a>.</p><p>For the latest version including betas, clone Git repository <strong>from</strong> <code>main</code> <strong>branch</strong> with:</p><pre><code class=\"language-text-x-trilium-auto\">git clone -b main https://github.com/triliumnext/trilium.git</code></pre><h2>Installation</h2><pre><code class=\"language-text-x-trilium-auto\">cd trilium\n\n# download all node dependencies\nnpm install\n\n# make sure the better-sqlite3 binary is there\nnpm rebuild\n\n# bundles &amp; minifies frontend JavaScript\nnpm run webpack</code></pre><h2>Run</h2><pre><code class=\"language-text-x-trilium-auto\">cd trilium\n\n# using nohup to make sure trilium keeps running after user logs out\nnohup TRILIUM_ENV=dev node src/www &amp;</code></pre><p>The application by default starts up on port 8080, so you can open your browser and navigate to <a href=\"http://localhost:8080\">http://localhost:8080</a> to access Trilium (replace \"localhost\" with your hostname).</p><h2>TLS</h2><p>Don't forget to <a href=\"#root/_help_l2VkvOwUNfZj\">configure TLS</a> which is required for secure usage!</p>",
+ "_help_J1Bb6lVlwU5T": "<aside class=\"admonition warning\"><p>This page describes manually installing Trilium on your server. <strong>Note that this is a not well supported way to install Trilium, problems may appear, information laid out here is quite out of date. It is recommended to use either</strong>&nbsp;<a class=\"reference-link\" href=\"#root/_help_rWX5eY045zbE\">Docker Server Installation</a>&nbsp;<strong>or</strong>&nbsp;<a class=\"reference-link\" href=\"#root/_help_3tW6mORuTHnB\">Packaged server installation</a><strong>.</strong></p></aside><h2>Requirements</h2><p>Trilium is a node.js application. Supported (tested) version of node.js is latest 14.X.X and 16.X.X. Trilium might work with older versions as well.</p><p>You can check your node version with this command (node.js needs to be installed):</p><pre><code class=\"language-text-x-trilium-auto\">node --version</code></pre><p>If your Linux distribution has only an outdated version of node.js, you can take a look at the installation instruction on node.js website, which covers most popular distributions.</p><h3>Dependencies</h3><p>There are some dependencies required. You can see command for Debian and its derivatives (like Ubuntu) below:</p><pre><code class=\"language-text-x-trilium-auto\">sudo apt install libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev</code></pre><h2>Installation</h2><h3>Download</h3><p>You can either download source code zip/tar from <a href=\"https://github.com/TriliumNext/Trilium/releases/latest\">https://github.com/TriliumNext/Trilium/releases/latest</a>.</p><p>For the latest version including betas, clone Git repository <strong>from</strong> <code>main</code> <strong>branch</strong> with:</p><pre><code class=\"language-text-x-trilium-auto\">git clone -b main https://github.com/triliumnext/trilium.git</code></pre><h2>Installation</h2><pre><code class=\"language-text-x-trilium-auto\">cd trilium\n\n# download all node dependencies\nnpm install\n\n# make sure the better-sqlite3 binary is there\nnpm rebuild\n\n# bundles &amp; minifies frontend JavaScript\nnpm run webpack</code></pre><h2>Run</h2><pre><code class=\"language-text-x-trilium-auto\">cd trilium\n\n# using nohup to make sure trilium keeps running after user logs out\nnohup TRILIUM_ENV=dev node src/www &amp;</code></pre><p>The application by default starts up on port 8080, so you can open your browser and navigate to <a href=\"http://localhost:8080\">http://localhost:8080</a> to access Trilium (replace \"localhost\" with your hostname).</p><p>Once the server is running, the console lists the addresses it can be reached on, including the ones other devices on your network can use.</p><h2>TLS</h2><p>Don't forget to <a href=\"#root/_help_l2VkvOwUNfZj\">configure TLS</a> which is required for secure usage!</p>",
"_help_DCmT6e7clMoP": "<p>As Trilium can be run in Docker it also can be deployed in Kubernetes. You can either use our Helm chart, a community Helm chart, or roll your own Kubernetes deployment.</p><p>The recommended way is to use a Helm chart.</p><h2>Root privileges</h2><p>By default, the Trilium container starts as root, gives the data directory to UID and GID <code>1000:1000</code> and then runs Trilium with those reduced privileges, so no init container is needed to fix the permissions. To use a different UID and GID, set the <code>USER_UID</code> and <code>USER_GID</code> environment variables.</p><p>Starting with v0.107.0, the container can also run without root, which a <code>restricted</code> Pod Security Standard requires. Set the user in the pod's security context, and <code>fsGroup</code> so that Kubernetes gives the volume to that group:</p><pre><code class=\"language-text-x-yaml\">securityContext:\n runAsUser: 1000\n runAsGroup: 1000\n runAsNonRoot: true\n fsGroup: 1000</code></pre><p>In that mode <code>USER_UID</code> and <code>USER_GID</code> are ignored. See the section on running as a non-root user in&nbsp;<a class=\"reference-link\" href=\"#root/_help_rWX5eY045zbE\">Using Docker</a> for what the data directory needs.</p><h2>Helm Charts</h2><p><a href=\"https://github.com/TriliumNext/helm-charts\">Official Helm chart</a> from TriliumNext Unofficial helm chart by <a href=\"https://github.com/ohdearaugustin\">ohdearaugustin</a>: <a href=\"https://github.com/ohdearaugustin/charts\">https://github.com/ohdearaugustin/charts</a></p><h2>Adding a Helm repository</h2><p>Below is an example of how</p><pre><code class=\"language-text-x-trilium-auto\">helm repo add trilium https://triliumnext.github.io/helm-charts\n\"trilium\" has been added to your repositories</code></pre><h2>How to install a chart</h2><p>After reviewing the <a href=\"https://github.com/TriliumNext/helm-charts/blob/main/charts/trilium/values.yaml\"><code>values.yaml</code></a> from the Helm chart, modifying as required and then creating your own:</p><pre><code class=\"language-text-x-trilium-auto\">helm install --create-namespace --namespace trilium trilium trilium/trilium -f values.yaml</code></pre><p>For more information on using Helm, please refer to the Helm documentation, or create a Discussion in the TriliumNext GitHub Organization.</p>",
"_help_klCWNks3ReaQ": "<p>Trilium does not support multiple users. In order to have two or more persons with their own set of notes, multiple server instances must be set up. It is also not possible to use multiple <a href=\"#root/_help_cbkrhQjrkKrh\">sync</a> servers.</p><p>To allow multiple server instances on a single physical server:</p><ul><li><p>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_3tW6mORuTHnB\">Packaged version for Linux</a>&nbsp;or&nbsp;<a class=\"reference-link\" href=\"#root/_help_J1Bb6lVlwU5T\">Manually</a>, if starting the server manually just specify a different port and data directory per instance:</p><pre><code class=\"language-text-x-trilium-auto\">TRILIUM_NETWORK_PORT=8080 TRILIUM_DATA_DIR=/path/to/your/data-dir-A /opt/trilium/trilium.sh</code></pre><p>For a second instance:</p><pre><code class=\"language-text-x-trilium-auto\">TRILIUM_NETWORK_PORT=8081 TRILIUM_DATA_DIR=/path/to/your/data-dir-B /opt/trilium/trilium.sh</code></pre><p>If using <code>systemd</code>, then set the <a href=\"https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service\">environment variables in the service configuration</a>.</p></li><li><p>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_rWX5eY045zbE\">Using Docker</a>, simply use two different containers, each with their own port binding and data directory.</p></li><li><p>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_moVgBcoxE3EK\">On NixOS</a>, the only possible way is to use Docker OCI containers or at least one NixOS container with its own service definition.</p></li></ul><p>For support or additional context, see the related <a href=\"https://github.com/orgs/TriliumNext/discussions/1642#discussioncomment-12768808\">GitHub Discussion</a>.</p>",
"_help_vcjrb3VVYPZI": "<p>Trilium is typically exposed to the internet behind a <strong>reverse proxy</strong>, which handles TLS termination, presents a single public entry point, and (optionally) lets you host multiple instances under one domain. Trilium itself keeps running on plain HTTP on its local port; the proxy sits in front of it.</p><p>This section collects provider-specific guides and the configuration that applies regardless of which proxy you use.</p><h2>Provider guides</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_ud6MShXL4WpO\">Nginx</a></li><li><a class=\"reference-link\" href=\"#root/_help_5ERVJb9s4FRD\">Traefik</a></li><li><a class=\"reference-link\" href=\"#root/_help_fDLvzOx29Pfg\">Apache using Docker</a></li></ul><h2>Applies to every proxy</h2><p>Regardless of the proxy you choose, make sure of the following:</p><ul><li><strong>Forward the WebSocket upgrade.</strong> Trilium uses a WebSocket for synchronization and live UI updates. Your proxy must pass the <code>Upgrade</code> and <code>Connection</code> headers through, otherwise the client will appear to load but never receive updates.</li><li><strong>Configure the trusted proxy.</strong> So that Trilium sees the real client IP (for rate limiting, logging, and secure cookies) rather than the proxy's address. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>.</li><li><strong>Terminate TLS at the proxy.</strong> See&nbsp;<a class=\"reference-link\" href=\"#root/_help_l2VkvOwUNfZj\">HTTPS (TLS)</a>.</li></ul><h2>Putting an authentication proxy in front of Trilium</h2><p>Some setups place a <strong>forward-auth / SSO layer</strong> (Authelia, Authentik, oauth2-proxy, or an OIDC plugin) at the proxy so that <em>every</em> request must pass an interactive login first.</p><p>This <strong>breaks synchronization and initial setup.</strong> Sync is a machine-to-machine process that runs unattended in the background — it has no browser and cannot complete an interactive login challenge. When the proxy intercepts a sync request, it returns its HTML login page instead of the expected JSON, and the client fails with an error such as:</p><pre><code class=\"language-text-x-trilium-auto\">Sync failed: Request to GET https://trilium.example.com/api/setup/status failed,\nerror: Unexpected token '&lt;', \"&lt;!doctype \"... is not valid JSON\n</code></pre><p>There are two ways to resolve this:</p><ul><li><strong>Preferred, use Trilium's built-in authentication.</strong> Don't gate Trilium at the proxy at all. Trilium can authenticate the web interface itself, including via <a href=\"#root/_help_x1lQNKQBqLcA\">OpenID Connect</a>. This leaves the sync endpoints free to authenticate the way they're designed to.</li><li><strong>Exempt the sync endpoints from the proxy's authentication.</strong> If you must keep auth at the proxy, exclude these paths from the forward-auth check:<ul><li><code>/api/setup/*</code></li><li><code>/api/login/sync</code></li><li><code>/api/sync/*</code></li></ul></li></ul><aside class=\"admonition note\"><p>This is safe: Trilium authenticates these endpoints itself. Sync uses a challenge-free HMAC handshake based on a shared secret, and the one-time setup seed request is password-protected — so exempting them at the proxy does not expose unauthenticated access to your data.</p></aside><p>An example for Nginx, where <code>/auth</code> is your forward-auth endpoint:</p><pre><code class=\"language-text-x-trilium-auto\">server {\n # ... TLS, server_name, etc. ...\n\n # Sync and setup endpoints authenticate themselves — skip forward-auth.\n location ~ ^/api/(sync|login/sync|setup) {\n auth_request off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n }\n\n # Everything else goes through forward-auth.\n location / {\n auth_request /auth;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n }\n}</code></pre>",
diff --git a/apps/server/src/routes/api/system_info.spec.ts b/apps/server/src/routes/api/system_info.spec.ts
index 814652a5f3..0126ffe422 100644
--- a/apps/server/src/routes/api/system_info.spec.ts
+++ b/apps/server/src/routes/api/system_info.spec.ts
@@ -28,9 +28,7 @@ vi.mock("os", () => ({
networkInterfaces: () => ({})
}));
-import systemInfoRoute, { buildNetworkUrl, collectNetworkAddresses, isCpuArchMismatch, isHostReachableOnNetwork } from "./system_info.js";
-
-type NetworkInterfaces = Parameters<typeof collectNetworkAddresses>[0];
+import systemInfoRoute, { isCpuArchMismatch } from "./system_info.js";
describe("System info API", () => {
afterEach(() => {
@@ -65,60 +63,4 @@ describe("System info API", () => {
state.cpuModel = "Intel";
expect(isCpuArchMismatch()).toBe(false);
});
-
- describe("collectNetworkAddresses", () => {
- it("drops internal and scope-bound IPv6 addresses, then sorts by LAN likelihood", () => {
- const interfaces = {
- lo: [{ address: "127.0.0.1", internal: true, family: "IPv4" }],
- eth0: [
- { address: "203.0.113.5", internal: false, family: "IPv4" },
- { address: "192.168.1.20", internal: false, family: "IPv4" },
- { address: "10.0.0.4", internal: false, family: "IPv4" },
- { address: "172.16.0.9", internal: false, family: "IPv4" },
- { address: "fe80::1", internal: false, family: "IPv6", scopeid: 4 },
- { address: "fd00::1", internal: false, family: "IPv6", scopeid: 0 }
- ]
- } as unknown as NetworkInterfaces;
-
- expect(collectNetworkAddresses(interfaces)).toEqual([
- "192.168.1.20", // 192.168.* ranks first
- "10.0.0.4", // then 10.*
- "172.16.0.9", // then 172.16–31.* private range
- "203.0.113.5", // then other IPv4
- "fd00::1" // IPv6 last; fe80::1 dropped (scopeid !== 0)
- ]);
- });
-
- it("returns an empty list when no usable interfaces exist", () => {
- expect(collectNetworkAddresses({})).toEqual([]);
- expect(collectNetworkAddresses({ lo: undefined } as unknown as NetworkInterfaces)).toEqual([]);
- });
- });
-
- describe("buildNetworkUrl", () => {
- it("builds a URL with the given protocol and port", () => {
- expect(buildNetworkUrl("http", "192.168.1.20", 37840)).toBe("http://192.168.1.20:37840");
- expect(buildNetworkUrl("https", "10.0.0.4", 8080)).toBe("https://10.0.0.4:8080");
- });
-
- it("wraps IPv6 literals in brackets", () => {
- expect(buildNetworkUrl("http", "fd00::1", 37840)).toBe("http://[fd00::1]:37840");
- });
- });
-
- describe("isHostReachableOnNetwork", () => {
- it("treats loopback bindings as unreachable", () => {
- expect(isHostReachableOnNetwork("127.0.0.1")).toBe(false);
- expect(isHostReachableOnNetwork("127.1.2.3")).toBe(false);
- expect(isHostReachableOnNetwork("localhost")).toBe(false);
- expect(isHostReachableOnNetwork("::1")).toBe(false);
- expect(isHostReachableOnNetwork(" LOCALHOST ")).toBe(false);
- });
-
- it("treats wildcard and specific interfaces as reachable", () => {
- expect(isHostReachableOnNetwork("0.0.0.0")).toBe(true);
- expect(isHostReachableOnNetwork("::")).toBe(true);
- expect(isHostReachableOnNetwork("192.168.1.20")).toBe(true);
- });
- });
});
diff --git a/apps/server/src/routes/api/system_info.ts b/apps/server/src/routes/api/system_info.ts
index e2648b1c14..7079cd54f3 100644
--- a/apps/server/src/routes/api/system_info.ts
+++ b/apps/server/src/routes/api/system_info.ts
@@ -4,6 +4,9 @@ import { arch, cpus, networkInterfaces } from "os";
import config from "../../services/config.js";
import host from "../../services/host.js";
+import {
+ buildNetworkUrl, collectNetworkAddresses, isHostReachableOnNetwork
+} from "../../services/network_addresses.js";
import port from "../../services/port.js";
import { isMac, isWindows } from "../../services/utils";
@@ -62,57 +65,6 @@ export const isCpuArchMismatch = () => {
}
};
-/**
- * Collects this host's non-internal network addresses, sorted by how likely
- * each is to be the reachable LAN address. Pure and exported so it can be
- * unit-tested without touching the real OS interfaces.
- */
-export function collectNetworkAddresses(interfaces: ReturnType<typeof networkInterfaces>): string[] {
- const addresses: string[] = [];
-
- for (const nets of Object.values(interfaces)) {
- if (!nets) continue;
- for (const net of nets) {
- if (net.internal) continue;
- if (net.family === "IPv6" && net.scopeid !== 0) continue;
- addresses.push(net.address);
- }
- }
-
- addresses.sort((a, b) => networkScore(a) - networkScore(b));
-
- return addresses;
-}
-
-function networkScore(addr: string): number {
- if (addr.startsWith("192.168.")) return 0;
- if (addr.startsWith("10.")) return 1;
- if (/^172\.(1[6-9]|2\d|3[01])\./.test(addr)) return 2;
- if (addr.includes(":")) return 4; // IPv6
- return 3;
-}
-
-/**
- * Builds a connectable URL from a host address, wrapping IPv6 literals in
- * brackets as required by the URL authority syntax. Pure and exported for
- * unit testing.
- */
-export function buildNetworkUrl(protocol: string, address: string, port: number): string {
- const host = address.includes(":") ? `[${address}]` : address;
- return `${protocol}://${host}:${port}`;
-}
-
-/**
- * Whether the configured listening host is reachable from other devices.
- * Returns `false` for loopback-only bindings (the Electron desktop default),
- * where the advertised LAN addresses can't actually be connected to. Pure and
- * exported for unit testing.
- */
-export function isHostReachableOnNetwork(host: string): boolean {
- const normalized = host.trim().toLowerCase();
- return normalized !== "localhost" && normalized !== "::1" && !normalized.startsWith("127.");
-}
-
export default {
systemChecks,
getNetworkAddresses
diff --git a/apps/server/src/services/network_addresses.spec.ts b/apps/server/src/services/network_addresses.spec.ts
new file mode 100644
index 0000000000..5f5aae2521
--- /dev/null
+++ b/apps/server/src/services/network_addresses.spec.ts
@@ -0,0 +1,100 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ buildNetworkUrl, collectNetworkAddresses, isHostReachableOnNetwork, listListeningUrls
+} from "./network_addresses.js";
+
+type NetworkInterfaces = Parameters<typeof collectNetworkAddresses>[0];
+
+describe("collectNetworkAddresses", () => {
+ it("drops internal and scope-bound IPv6 addresses, then sorts by LAN likelihood", () => {
+ const interfaces = {
+ lo: [{ address: "127.0.0.1", internal: true, family: "IPv4" }],
+ eth0: [
+ { address: "203.0.113.5", internal: false, family: "IPv4" },
+ { address: "192.168.1.20", internal: false, family: "IPv4" },
+ { address: "10.0.0.4", internal: false, family: "IPv4" },
+ { address: "172.16.0.9", internal: false, family: "IPv4" },
+ { address: "fe80::1", internal: false, family: "IPv6", scopeid: 4 },
+ { address: "fd00::1", internal: false, family: "IPv6", scopeid: 0 }
+ ]
+ } as unknown as NetworkInterfaces;
+
+ expect(collectNetworkAddresses(interfaces)).toEqual([
+ "192.168.1.20", // 192.168.* ranks first
+ "10.0.0.4", // then 10.*
+ "172.16.0.9", // then 172.16–31.* private range
+ "203.0.113.5", // then other IPv4
+ "fd00::1" // IPv6 last; fe80::1 dropped (scopeid !== 0)
+ ]);
+ });
+
+ it("returns an empty list when no usable interfaces exist", () => {
+ expect(collectNetworkAddresses({})).toEqual([]);
+ expect(collectNetworkAddresses({ lo: undefined } as unknown as NetworkInterfaces)).toEqual([]);
+ });
+});
+
+describe("buildNetworkUrl", () => {
+ it("builds a URL with the given protocol and port", () => {
+ expect(buildNetworkUrl("http", "192.168.1.20", 37840)).toBe("http://192.168.1.20:37840");
+ expect(buildNetworkUrl("https", "10.0.0.4", 8080)).toBe("https://10.0.0.4:8080");
+ });
+
+ it("wraps IPv6 literals in brackets", () => {
+ expect(buildNetworkUrl("http", "fd00::1", 37840)).toBe("http://[fd00::1]:37840");
+ });
+});
+
+describe("isHostReachableOnNetwork", () => {
+ it("treats loopback bindings as unreachable", () => {
+ expect(isHostReachableOnNetwork("127.0.0.1")).toBe(false);
+ expect(isHostReachableOnNetwork("127.1.2.3")).toBe(false);
+ expect(isHostReachableOnNetwork("localhost")).toBe(false);
+ expect(isHostReachableOnNetwork("::1")).toBe(false);
+ expect(isHostReachableOnNetwork(" LOCALHOST ")).toBe(false);
+ });
+
+ it("treats wildcard and specific interfaces as reachable", () => {
+ expect(isHostReachableOnNetwork("0.0.0.0")).toBe(true);
+ expect(isHostReachableOnNetwork("::")).toBe(true);
+ expect(isHostReachableOnNetwork("192.168.1.20")).toBe(true);
+ });
+});
+
+describe("listListeningUrls", () => {
+ const interfaces = {
+ lo: [{ address: "127.0.0.1", internal: true, family: "IPv4" }],
+ eth0: [
+ { address: "10.0.0.4", internal: false, family: "IPv4" },
+ { address: "192.168.1.20", internal: false, family: "IPv4" },
+ { address: "fd00::1", internal: false, family: "IPv6", scopeid: 0 }
+ ]
+ } as unknown as NetworkInterfaces;
+
+ it("lists localhost and the LAN addresses for a wildcard host", () => {
+ expect(listListeningUrls("http", "0.0.0.0", 8080, interfaces)).toEqual({
+ local: "http://localhost:8080",
+ network: ["http://192.168.1.20:8080", "http://10.0.0.4:8080"]
+ });
+ expect(listListeningUrls("https", "::", 8443, interfaces)).toEqual({
+ local: "https://localhost:8443",
+ network: ["https://192.168.1.20:8443", "https://10.0.0.4:8443", "https://[fd00::1]:8443"]
+ });
+ });
+
+ it("lists only the configured address for a loopback or specific host", () => {
+ expect(listListeningUrls("http", "127.0.0.1", 8080, interfaces)).toEqual({
+ local: "http://127.0.0.1:8080",
+ network: []
+ });
+ expect(listListeningUrls("http", "::1", 8080, interfaces)).toEqual({
+ local: "http://[::1]:8080",
+ network: []
+ });
+ expect(listListeningUrls("http", "10.0.0.4", 8080, interfaces)).toEqual({
+ local: undefined,
+ network: ["http://10.0.0.4:8080"]
+ });
+ });
+});
diff --git a/apps/server/src/services/network_addresses.ts b/apps/server/src/services/network_addresses.ts
new file mode 100644
index 0000000000..ec3189c918
--- /dev/null
+++ b/apps/server/src/services/network_addresses.ts
@@ -0,0 +1,82 @@
+import type { networkInterfaces } from "os";
+
+/**
+ * Collects this host's non-internal network addresses, sorted by how likely
+ * each is to be the reachable LAN address. Pure and exported so it can be
+ * unit-tested without touching the real OS interfaces.
+ */
+export function collectNetworkAddresses(interfaces: ReturnType<typeof networkInterfaces>): string[] {
+ const addresses: string[] = [];
+
+ for (const nets of Object.values(interfaces)) {
+ if (!nets) continue;
+ for (const net of nets) {
+ if (net.internal) continue;
+ if (net.family === "IPv6" && net.scopeid !== 0) continue;
+ addresses.push(net.address);
+ }
+ }
+
+ addresses.sort((a, b) => networkScore(a) - networkScore(b));
+
+ return addresses;
+}
+
+/**
+ * Builds a connectable URL from a host address, wrapping IPv6 literals in
+ * brackets as required by the URL authority syntax. Pure and exported for
+ * unit testing.
+ */
+export function buildNetworkUrl(protocol: string, address: string, port: number): string {
+ const host = address.includes(":") ? `[${address}]` : address;
+ return `${protocol}://${host}:${port}`;
+}
+
+/**
+ * Whether the configured listening host is reachable from other devices.
+ * Returns `false` for loopback-only bindings (the Electron desktop default),
+ * where the advertised LAN addresses can't actually be connected to. Pure and
+ * exported for unit testing.
+ */
+export function isHostReachableOnNetwork(host: string): boolean {
+ const normalized = host.trim().toLowerCase();
+ return normalized !== "localhost" && normalized !== "::1" && !normalized.startsWith("127.");
+}
+
+/**
+ * Lists the URLs the server answers on, for the startup banner. A wildcard host yields
+ * `localhost` plus every LAN address (IPv4 only for `0.0.0.0`); any other host yields its own
+ * address, as `local` when it is loopback and in `network` otherwise.
+ */
+export function listListeningUrls(
+ protocol: string,
+ host: string,
+ port: number,
+ interfaces: ReturnType<typeof networkInterfaces>
+): { local: string | undefined; network: string[] } {
+ const normalized = host.trim();
+
+ if (normalized === "0.0.0.0" || normalized === "::" || normalized === "") {
+ const addresses = collectNetworkAddresses(interfaces)
+ .filter((addr) => normalized !== "0.0.0.0" || !addr.includes(":"));
+
+ return {
+ local: buildNetworkUrl(protocol, "localhost", port),
+ network: addresses.map((addr) => buildNetworkUrl(protocol, addr, port))
+ };
+ }
+
+ const url = buildNetworkUrl(protocol, normalized, port);
+
+ return isHostReachableOnNetwork(normalized)
+ ? { local: undefined, network: [url] }
+ : { local: url, network: [] };
+}
+
+function networkScore(addr: string): number {
+ if (addr.startsWith("192.168.")) return 0;
+ if (addr.startsWith("10.")) return 1;
+ if (/^172\.(1[6-9]|2\d|3[01])\./.test(addr)) return 2;
+ if (addr.includes(":")) return 4; // IPv6
+ return 3;
+}
diff --git a/apps/server/src/www.ts b/apps/server/src/www.ts
index b2b36ce693..37d6b99612 100644
--- a/apps/server/src/www.ts
+++ b/apps/server/src/www.ts
@@ -3,6 +3,7 @@ import type { Express } from "express";
import fs from "fs";
import http from "http";
import https from "https";
+import { networkInterfaces } from "os";
import tmp from "tmp";
import buildApp from "./app.js";
@@ -12,9 +13,11 @@ import { startCpuProfiler, writeCpuProfile } from "./services/cpu_profiler.js";
import { registerOcrHandlers } from "./services/handlers.js";
import host from "./services/host.js";
import { registerServerLlmExtensions } from "./services/llm/index.js";
+import { listListeningUrls } from "./services/network_addresses.js";
import port from "./services/port.js";
import { installProcessErrorHandlers, markAppReady } from "./services/process_errors.js";
import { isScriptingEnabled } from "./services/scripting_guard.js";
+import { isElectron } from "./services/utils.js";
import { publishHealthcheckTarget } from "./services/healthcheck.js";
import { getDbSize } from "./services/sql_init.js";
import { isHttpAttachableMessagingProvider } from "./services/ws_messaging_provider.js";
@@ -207,6 +210,7 @@ function startHttpServer(app: Express) {
httpServer.on("listening", () => {
if (listenOnTcp) {
getLog().info(`Listening on port ${port}`);
+ printListeningUrls();
} else {
getLog().info(`Listening on unix socket ${host}`);
}
@@ -217,3 +221,24 @@ function startHttpServer(app: Express) {
return httpServer;
}
+
+/**
+ * Prints the URLs the server answers on. It writes to the console only, since the log file ends
+ * up in bug reports and the list can hold a public address. Desktop has no console to read, and
+ * in a container the interfaces belong to the container network rather than the host.
+ */
+function printListeningUrls() {
+ if (isElectron || fs.existsSync("/.dockerenv") || fs.existsSync("/run/.containerenv")) {
+ return;
+ }
+
+ const protocol = config["Network"]["https"] ? "https" : "http";
+ const { local, network } = listListeningUrls(protocol, host, port, networkInterfaces());
+
+ if (local) {
+ console.log(`🌐 Local: ${local}`);
+ }
+ for (const [index, url] of network.entries()) {
+ console.log(`${index === 0 ? "🌐 Network: " : " "}${url}`);
+ }
+}
diff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Manually.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Manually.md
index afc7661e6a..3ef959460b 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Manually.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Manually.md
@@ -60,6 +60,8 @@ nohup TRILIUM_ENV=dev node src/www &
The application by default starts up on port 8080, so you can open your browser and navigate to [http://localhost:8080](http://localhost:8080) to access Trilium (replace "localhost" with your hostname).
+Once the server is running, the console lists the addresses it can be reached on, including the ones other devices on your network can use.
+
## TLS
Don't forget to [configure TLS](../HTTPS%20\(TLS\).md) which is required for secure usage!
\ No newline at end of file
diff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Packaged version for Linux.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Packaged version for Linux.md
index caf96f7fba..22fc0c8941 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Packaged version for Linux.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/1. Installing the server/Packaged version for Linux.md
@@ -9,6 +9,7 @@ This is essentially Trilium sources + node modules + node.js runtime packaged in
* `cd trilium-linux-x64-server`
* `./trilium.sh`
* you can open the browser and open http://\[your-server-hostname\]:8080 and you should see Trilium initialization page
+* the console lists the addresses the server can be reached on, so you can also copy one from there
The problem with above steps is that once you close the SSH connection, the Trilium process is terminated. To avoid that, you have two options: