Complete Guide: Always-On Mac Server with MLX, oMLX & QwenPaw
Headless MLX inference with oMLX, QwenPaw, Caddy, Tailscale, and Cloudflare — verified end to end.

The foundation guide for local AI on Apple Silicon.
This guide builds a headless, always-on Mac mini that survives reboot without any GUI intervention, serves local models through oMLX with persistent API keys, runs the QwenPaw agent framework as a system service, and exposes everything through Caddy + Cloudflare Tunnel with Tailscale for SSH (and optionally HTTPS) access. The whole stack runs at zero marginal inference cost and never sends data off the machine.
Tested Environment
Everything in this guide was verified on the following setup. If your versions are close, the commands should work unchanged.
| Component | Version | Notes |
|---|---|---|
| macOS | 15.x (Sequoia) or later | Required for oMLX |
| Chip | Apple Silicon (M1/M2/M3/M4/M5) | Required for MLX and oMLX |
| Homebrew | 4.x or later | Package manager for oMLX, Caddy, and Tailscale |
| uv | 0.8.x or later | Python version + package manager |
| Python (MLX venv) | 3.11.x | Managed by uv at ~/.mlx-venv |
| Python (QwenPaw) | 3.12.x | Bundled by QwenPaw's installer |
| MLX | 0.32.x | Apple's ML framework |
| mlx-lm | 0.32.x | LLM extensions for MLX |
| oMLX | latest via jundot/omlx |
Inference server + admin dashboard |
| QwenPaw | latest via agentscope.io |
Agent framework + web console |
| Caddy | 2.x | Reverse proxy + authentication layer |
| Tailscale | latest via --cask |
Mesh VPN, SSH, TLS termination |
| cloudflared | latest via Homebrew | Public access via custom domain |
| jq | latest via Homebrew | JSON processor (used throughout) |
| yq | latest via Homebrew | YAML processor (used later) |
Note: Version numbers above reflect the state of the ecosystem as of 2026-10, the date this guide was last verified end-to-end. Run
brew --version,uv --version, or the relevant--versionflag after each install to confirm what you have.
Part 1: Prepare macOS for Headless Server Mode
These steps ensure your Mac never sleeps, is accessible remotely, and boots into a usable state without manual intervention.
1.1 Prevent System Sleep
Run this in Terminal to disable all sleep modes permanently:
sudo pmset -a disablesleep 1 sleep 0 disksleep 0 displaysleep 0 standby 0 autopoweroff 0 powernap 0
Expected output: You'll be prompted for your password. After entry, no confirmation message appears — that's normal.
Verify with:
pmset -g
Expected output:
System-wide power settings:
SleepDisabled 1
Currently in use:
standby 0
Sleep On Power Button 1
autorestartatconnect 0
autorestart 0
SleepServices 0
powernap 0
networkoversleep 0
disksleep 0
sleep 0 (sleep prevented by powerd, bluetoothd)
ttyskeepawake 1
displaysleep 0
tcpkeepalive 1
powermode 0
womp 1
Note: On macOS Ventura (13) and later,
pmsetreports the disablesleep setting asSleepDisabled 1instead ofdisablesleep 1. This is expected — it means the same thing.The annotation
(sleep prevented by powerd, bluetoothd)next tosleep 0is informational, not an error. It simply means that in addition to yourpmsetsettings, system daemons are also actively preventing sleep. Your server will stay awake.
1.1b Prevent App Nap with caffeinate
pmset stops the system from sleeping, but macOS can still throttle background processes via App Nap. On an always-on server, App Nap causes services to respond slowly — a request that should take milliseconds can hang for seconds while the process is deprioritized. This is especially noticeable on MLX inference: token generation rate can drop dramatically when macOS decides the process is "idle" between requests.
The caffeinate command prevents App Nap by holding IOKit power assertions:
caffeinate -dimsu -t 2147483647
| Flag | Effect |
|---|---|
-d |
Prevent the display from sleeping |
-i |
Prevent idle system sleep — this is what blocks App Nap |
-m |
Prevent disk idle sleep |
-s |
Prevent system sleep on AC power |
-u |
Declare the user is active |
-t 2147483647 |
Hold the assertion for the maximum duration (~68 years) |
To make it persistent across reboots, create a dedicated launch agent. This runs independently of your other services, so it survives their restarts:
cat > ~/Library/LaunchAgents/com.caffeinate.server.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.caffeinate.server</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/caffeinate</string>
<string>-dimsu</string>
<string>-t</string>
<string>2147483647</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
Load it:
launchctl bootout gui/$(id -u)/com.caffeinate.server 2>/dev/null
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.caffeinate.server.plist
Verify it's running:
launchctl list | grep caffeinate
Expected output:
- 0 com.caffeinate.server
Confirm the assertions are active:
pmset -g assertions | grep -A 5 "caffeinate"
Expected output: A list showing PreventUserIdleSystemSleep, PreventUserIdleDisplaySleep, and related assertions attributed to caffeinate.
Note: Some reports suggest that
pmset -g assertionson certain macOS versions no longer lists all assertions. Even if the output is sparse, thecaffeinateprocess running underlaunchctlis sufficient — the assertions are held at the kernel level regardless of whatpmsetdisplays.
1.2 Enable SSH (Remote Login)
On macOS Catalina (10.15) and later, the systemsetup command requires Full Disk Access to toggle Remote Login. Running it without that permission will fail with:
setremotelogin: Turning Remote Login on or off requires Full Disk Access privileges.
This is a macOS security feature (TCC), and sudo alone does not bypass it. Follow these steps to fix it permanently.
Step 1: Grant Full Disk Access to Terminal
- Open System Settings.
- Go to Privacy & Security → Full Disk Access.
- Click the + button.
- Navigate to Applications → Utilities and select Terminal.app (or your terminal of choice, e.g., iTerm).
- Toggle Terminal on in the list.
- Quit Terminal completely (
Cmd+Q) and reopen it. The permission only takes effect for new sessions.
Step 2: Enable Remote Login
Now run the command. It will succeed without the permission error:
sudo systemsetup -setremotelogin on
Expected output: setremotelogin: remote login is now on
Verify:
sudo systemsetup -getremotelogin
Expected output: Remote Login: On
Now you can SSH from another Mac: ssh username@your-mac-ip
1.3 Enable Auto-Login (Required for LaunchAgents)
launchd user agents only start after a user logs in. Without auto-login, your services won't run after a reboot.
- Open System Settings → Users & Groups
- Click Automatic Login → select your user account
- Enter your password when prompted
Note: FileVault must be OFF for auto-login to work. Go to System Settings → Privacy & Security → FileVault and turn it off if it's enabled. This is acceptable for a physically secure home server.
1.4 LaunchAgents vs. LaunchDaemons (Understanding the Difference)
As you build this server, you'll encounter two types of background services. It's important to know the difference:
- LaunchAgents (
~/Library/LaunchAgents/) run only after you log in to the Mac. The graphical user interface (WindowServerandloginwindow) must be running. If the Mac boots headless and fails to start the GUI, LaunchAgents never start. Examples in this guide: caffeinate. - LaunchDaemons (
/Library/LaunchDaemons/) run at system boot, long before any user logs in. They run in the background and do not need a GUI. Examples in this guide: Caddy, oMLX, QwenPaw, and cloudflared.
Why does this matter? If your Mac mini reboots but the desktop session gets stuck (which happens on headless Macs), your LaunchAgents won't load. By installing the core external-access services (oMLX, Caddy, QwenPaw, and cloudflared) as LaunchDaemons, we guarantee you can reach the server from the internet even if the GUI hangs.
If the GUI does fail to start, SSH in and run this diagnostic to see what's happening:
echo "=== Login window running? ===" && pgrep -l loginwindow
echo "=== WindowServer running? ===" && pgrep -l WindowServer
If both return nothing, the GUI never started. Check that FileVault is OFF, auto-login is enabled, and consider adding an HDMI dummy plug (a cheap hardware trick that forces the Mac to output a video signal so WindowServer starts).
Managing LaunchDaemons: Because they run in the system domain, you must use
sudoand thesystem/path to manage them. For example:sudo launchctl kickstart -k system/com.caddy.server. Attempting to usegui/$(id -u)will fail withCould not find service.
1.5 Optional: Menu Bar Server Mode Toggle
For quick control without terminal, install the mac-server-mode menu bar app:
git clone https://github.com/thairc-dev/mac-server-mode.git && cd mac-server-mode && ./build.sh && nohup ./mac-server-mode >/dev/null 2>&1 & ./install-launch-agent.sh
A ⚡ icon appears in your menu bar. Press Ctrl + Option + Cmd + S to toggle server mode (screen off, system awake).
Part 2: Install uv & Python 3.11
2.1 Install uv
uv is a fast, all-in-one Python package and version manager written in Rust. Install it via the official one-liner:
curl -LsSf https://astral.sh/uv/install.sh | sh && source ~/.zshrc && uv --version
Expected output: Installation progress bars, then uv 0.x.x.
2.2 Install Python 3.11 with uv
Install Python 3.11 as a uv-managed Python:
uv python install 3.11 && uv python list | grep 3.11
Expected output: Download progress, then the installed Python 3.11 version.
2.3 Create a Virtual Environment for MLX
Create a dedicated virtual environment, activate it, and verify the version in one go:
uv venv --python 3.11 ~/.mlx-venv && source ~/.mlx-venv/bin/activate && python --version && python -c "import platform; print(platform.processor())"
Expected output:
Python 3.11.x
arm
Critical: If you see
i386instead ofarm, you have a Rosetta (x86) Python. Reinstall Python 3.11 through uv and start over.
Part 3: Install MLX Framework
MLX is Apple's native machine learning framework for Apple Silicon.
With your virtual environment activated, install the framework and verify it:
source ~/.mlx-venv/bin/activate && uv pip install mlx mlx-lm && python -c "import mlx.core as mx; print(mx.__version__)"
Expected output: Successfully installed mlx-x.x.x mlx-lm-x.x.x ... followed by 0.32.x.
Note: The top-level
mlxmodule does not export__version__. If you trypython -c "import mlx; print(mlx.__version__)", you'll getAttributeError: module 'mlx' has no attribute '__version__'. The version attribute lives onmlx.core. Alternatively, you can read the version from package metadata:python -c "import importlib.metadata as md; print(md.version('mlx'))"
Part 4: Install oMLX (Web Dashboard + Background Service)
oMLX is an LLM inference server optimized for Apple Silicon, built on the MLX framework. It provides continuous batching, tiered KV caching (hot in-memory + cold SSD), and a web-based admin dashboard for managing models. It is actively maintained and ships as a Homebrew formula with native launchd service integration.
Note: oMLX is a community project maintained by
jundot. It is built directly on top of Apple's MLX framework (which is official).
Platform requirement: oMLX requires Apple Silicon (M1/M2/M3/M4/M5) and macOS 15.0 (Sequoia) or later. Intel Macs and earlier macOS versions are rejected during installation.
4.1 Install Homebrew
If you don't already have Homebrew, install it and set up your PATH in one command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile && eval "$(/opt/homebrew/bin/brew shellenv)" && brew --version
Expected output: Installation progress messages, then Homebrew 4.x.x.
Note: If Homebrew is already installed, the installer will detect it and skip installation. You can safely run this command again.
4.1b Install jq and yq
This guide uses jq heavily for JSON manipulation (oMLX keys, QwenPaw config) and yq for YAML (useful for Cloudflare tunnel config and future service edits). Install both now so later steps don't fail with jq: command not found or yq: command not found.
brew install jq yq
Expected output: Homebrew installs both formulae, ending with jq and yq version numbers.
Verify:
jq --version
yq --version
Expected output:
jq-1.7.x
yq (https://github.com/mikefarah/yq/) version v4.x.x
Why here?
jqis first used in §4.3 to inject the oMLX API keys into~/.omlx/settings.json. Installing it before that step avoids the most common “command not found” error in this guide.yqis not strictly required by the commands below, but it's the right YAML companion for editing~/.cloudflared/config.ymland other configs later.
4.2 Tap, Trust, and Install oMLX
Run all three steps in one command:
brew tap jundot/omlx https://github.com/jundot/omlx && brew trust jundot/omlx && brew install jundot/omlx/omlx
Expected output:
==> Tapping jundot/omlx
Cloning into '/opt/homebrew/Library/Taps/jundot/homebrew-omlx'...
Tapped 1 formula.
==> Successfully trusted tap jundot/omlx.
==> Installing omlx from jundot/omlx
/opt/homebrew/Cellar/omlx/x.x.x: ...
Why
brew trustis needed: Recent versions of Homebrew refuse to load formulas from third-party taps unless you explicitly trust them — a security feature to prevent arbitrary code execution from untrusted sources. If you skip this, you'll seeError: Refusing to load formula jundot/omlx/omlx from untrusted tap jundot/omlx.
4.3 Set the API Keys (The Right Way)
oMLX uses two distinct keys, and confusing them is the most common setup error:
| Key | Purpose | Where It's Used |
|---|---|---|
api_key |
Authenticates inference requests. | The /v1/* endpoints (clients send this as a Bearer token). |
secret_key |
Signs the session cookies for the Admin Dashboard. | The web UI at /admin. Prevents you from being logged out on restart. |
The correct home for these keys is ~/.omlx/settings.json. While oMLX can read an environment variable (OMLX_API_KEY), putting it in a Homebrew-managed plist is fragile. The next time you run brew upgrade omlx, Homebrew will rewrite the plist and wipe your key, locking you out.
Prerequisite: This step requires
jq, which you installed in §4.1b.
Run this block to generate strong cryptographic keys and inject them directly into oMLX's configuration file:
# 1. Generate keys (api_key gets a suffix, secret_key is base hex)
BASE_KEY=$(openssl rand -hex 32)
API_KEY="${BASE_KEY}@81"
# 2. Ensure the directory exists
mkdir -p ~/.omlx
# 3. Inject into settings.json (creating it if missing)
if [ -f ~/.omlx/settings.json ]; then
jq --arg ak "$API_KEY" --arg sk "$BASE_KEY" \
'.auth = {api_key: $ak, secret_key: $sk}' \
~/.omlx/settings.json > ~/.omlx/settings.json.tmp && mv ~/.omlx/settings.json.tmp ~/.omlx/settings.json
else
jq -n --arg ak "$API_KEY" --arg sk "$BASE_KEY" \
'{auth: {api_key: $ak, secret_key: $sk}}' > ~/.omlx/settings.json
fi
# 4. Lock down file permissions
chmod 600 ~/.omlx/settings.json
# 5. Print the keys so you can save them for QwenPaw
echo "API Key: $(jq -r '.auth.api_key' ~/.omlx/settings.json)"
echo "Secret Key: $(jq -r '.auth.secret_key' ~/.omlx/settings.json)"
Expected output: Two long random strings. Save the API Key (the one ending in @81) — you will need it for QwenPaw in §5.2.
4.3b Rotating the API Key Later
If you ever need to change the keys, do not edit settings.json manually or use the admin UI (which might desync your QwenPaw config). Re-run the generation block from §4.3.
Because we are using a custom LaunchDaemon (see §4.4) that does not hardcode the keys in the plist, you simply need to restart oMLX and update QwenPaw:
sudo launchctl kickstart -k system/com.omlx.server
jq -r '.auth.api_key' ~/.omlx/settings.json # Copy this into QwenPaw's config
4.4 Start oMLX as an Always-On Background Service
Because we want oMLX to start at boot (even if the GUI fails), we will run it as a LaunchDaemon. But instead of relying on Homebrew's brew services (which wipes custom env vars on upgrade), we create our own daemon that simply points to the Homebrew binary. oMLX will read the keys directly from settings.json.
First, completely remove the old Homebrew LaunchAgent to prevent port conflicts:
brew services stop omlx 2>/dev/null
launchctl bootout gui/$(id -u)/sh.brew.omlx 2>/dev/null
rm -f ~/Library/LaunchAgents/sh.brew.omlx.plist
Now create the LaunchDaemon:
USER_NAME=$(whoami)
HOME_DIR=$HOME
sudo tee /Library/LaunchDaemons/com.omlx.server.plist > /dev/null << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.omlx.server</string>
<key>UserName</key>
<string>${USER_NAME}</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/omlx</string>
<string>serve</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>${HOME_DIR}</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>${HOME_DIR}</string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${HOME_DIR}/.local/bin</string>
</dict>
<key>StandardOutPath</key>
<string>/tmp/omlx.out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/omlx.err.log</string>
</dict>
</plist>
EOF
sudo launchctl bootout system/com.omlx.server 2>/dev/null
# Wait for the previous instance to fully unload before reloading
# (prevents `Bootstrap failed: 5: Input/output error` from a SIGTERM race)
for _ in 1 2 3 4 5; do
sudo launchctl list 2>/dev/null | grep -q "com.omlx.server" || break
sleep 1
done
sudo launchctl bootstrap system /Library/LaunchDaemons/com.omlx.server.plist
sleep 3
sudo launchctl list | grep omlx
Expected output:
12345 0 com.omlx.server
Verify the migration actually landed — no leftover Homebrew state, no legacy plist:
# The three checks below should all print ✅
brew services list | grep -i omlx && echo "⚠️ brew still tracks omlx" || echo "✅ brew no longer tracks omlx"
[ -f ~/Library/LaunchAgents/sh.brew.omlx.plist ] && echo "⚠️ legacy plist still exists" || echo "✅ legacy plist removed"
sudo launchctl list | grep -q "com.omlx.server" && echo "✅ com.omlx.server loaded" || echo "❌ com.omlx.server NOT loaded"
Confirm the process is listening on port 8000:
lsof -nP -iTCP:8000 -sTCP:LISTEN | tail -1
Expected output:
Python 12345 night-thoughts ... TCP 127.0.0.1:8000 (LISTEN)
A note on process names. You'll see
Pythoninstead ofomlxin thelsofoutput. That's because/opt/homebrew/bin/omlxis a Python shebang script —lsofreports the kernel's process name (the interpreter for shebang scripts), not theargv[0]basename. If you want the actual command name, runps -p 12345 -o comm,argsand you'll seeomlx-serverwith the full path. Same process, different tools, different names. Don't be alarmed.If
bootstrapfails with5: Input/output error: the previous instance hadn't fully exited when the new plist was loaded. The bounded polling loop above prevents this in normal use. If you hit it anyway,sudo launchctl list | grep omlxwill show whether the label is still registered — wait 3 seconds and re-run thebootstrapline.
4.4b Upgrading oMLX Later (Homebrew + LaunchDaemon Notice)
oMLX is installed via Homebrew but runs under our custom LaunchDaemon (com.omlx.server), not under brew services. This has an important consequence you must remember every time you upgrade it.
brew upgrade omlx does three things:
- It downloads and installs the new oMLX release into
/opt/homebrew/Cellar/omlx/<new-version>/. - It atomically repoints the stable symlink
/opt/homebrew/bin/omlxto the new version. - It does not restart your custom LaunchDaemon, and it does not touch
/Library/LaunchDaemons/com.omlx.server.plist.
So immediately after brew upgrade omlx finishes, the following is true:
sudo launchctl list | grep omlxstill showscom.omlx.serverrunning.- Your oMLX API still responds on
http://localhost:8000. - But the running process is still executing the old binary image from memory.
- The new version on disk is not in use until launchd restarts the process.
Because our plist points to the symlink /opt/homebrew/bin/omlx (not a versioned Cellar path), the upgrade itself is safe — it will not break the daemon on next start. But you must manually restart the daemon for the new version to actually run.
After every brew upgrade omlx, run:
sudo launchctl kickstart -k system/com.omlx.server
Then verify that the daemon came back up and the new version is live:
sudo launchctl list | grep omlx
tail -20 /tmp/omlx.err.log
API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json)
curl -s -H "Authorization: Bearer $API_KEY" http://localhost:8000/v1/models
The expected output:
launchctl listshowscom.omlx.serverwith a PID and exit code0.- The error log shows a clean startup with the new version string.
- The
curlcall returns a200JSON body like{"object":"list","data":[...]}, not{"detail":"API key required"}or a401.
Do not use brew services restart omlx. You removed the Homebrew-managed service in §4.4 on purpose. Using brew services at this point would recreate its own plist, reintroduce port conflicts, and potentially wipe configuration.
If you prefer to combine upgrade and restart in one command:
brew upgrade omlx && sudo launchctl kickstart -k system/com.omlx.server
A full reboot also loads the new version (because launchd re-reads the plist and resolves the symlink at boot), but a kickstart is faster and lets you inspect logs immediately.
4.5 Open the Admin Dashboard
oMLX binds to http://localhost:8000 by default. Open the admin dashboard in your browser:
http://localhost:8000/admin
Note: The dashboard lives at
/admin, not/. Hitting the root URL returns a 404 by design. Log in using thesecret_keyyou generated in §4.3.
4.6 Verify the API Key Works
Before moving on, confirm the key is accepted:
API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json)
curl -s -H "Authorization: Bearer $API_KEY" http://localhost:8000/v1/models
Expected output: {"object":"list","data":[]} — an empty list is correct at this stage because no model is loaded yet. The important thing is that you don't see {"detail":"API key required"} or a 401.
4.7 Download & Deploy a Model
- In the admin dashboard (
http://localhost:8000/admin), go to the Models section - Search Hugging Face for MLX models (e.g.,
mlx-community/Qwen3.5-4B-8bit) - Click Download — watch the progress bar
- Configure per-model settings (sampling parameters, context length, etc.)
- Click Load to start serving
Verify the model is live:
API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json)
curl -s -H "Authorization: Bearer $API_KEY" http://localhost:8000/v1/models
Expected output:
{"object":"list","data":[{"id":"mlx-community/Qwen3.5-4B-8bit","object":"model"}]}
Note: oMLX provides both OpenAI-compatible (
/v1/chat/completions) and Anthropic-compatible (/v1/messages) endpoints. It also supports/v1/embeddings,/v1/rerank, and/v1/responsesfor broader compatibility.
Part 5: Install QwenPaw (Agent Framework)
QwenPaw is a local-first AI agent framework that can connect to your oMLX-served models.
5.1 Install via One-Line Script
The installer writes a qwenpaw wrapper to ~/.qwenpaw/bin/ and adds it to your PATH via ~/.zshrc. Because your current shell session hasn't re-read that file yet, the command needs a source ~/.zshrc in between:
curl -fsSL https://qwenpaw.agentscope.io/install.sh | bash && source ~/.zshrc && qwenpaw init --defaults
Expected output:
[qwenpaw] QwenPaw installed successfully
[qwenpaw] Wrapper created at /Users/<you>/.qwenpaw/bin/qwenpaw
[qwenpaw] Updated /Users/<you>/.zshrc
✅ Configuration initialized at ~/.qwenpaw/config.json
✅ Default model backend configured
If you already ran the installer and got
command not found: qwenpaw: the install itself succeeded — you just need to reload your shell. Runsource ~/.zshrc && qwenpaw init --defaultsand continue.
This script installs QwenPaw into ~/.qwenpaw with a self-contained uv-managed Python environment. It automatically installs uv, creates a virtual environment, and downloads dependencies without requiring manual Python setup.
5.2 Configure QwenPaw to Use oMLX
Write the QwenPaw config in one command. Note that the api_key here must match the api_key in ~/.omlx/settings.json:
API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json)
cat > ~/.qwenpaw/config.json << EOF
{
"model": {
"backend": "openai",
"base_url": "http://localhost:8000/v1",
"api_key": "${API_KEY}",
"model_name": "mlx-community/Qwen3.5-4B-8bit"
}
}
EOF
If
~/.qwenpaw/config.jsonalready exists — for example, if QwenPaw has written preferences or other settings — do not overwrite it with this heredoc. Usejqto update just theapi_keyfield:API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json) jq --arg key "$API_KEY" '.model.api_key = $key' ~/.qwenpaw/config.json > ~/.qwenpaw/config.json.tmp && mv ~/.qwenpaw/config.json.tmp ~/.qwenpaw/config.json
Path note:
base_urlmust include the/v1suffix. QwenPaw's OpenAI client appends/models,/chat/completions, etc. afterbase_url, so a missing/v1sends requests to the wrong paths.
5.3 Start QwenPaw
source ~/.zshrc && qwenpaw app
Expected output:
QwenPaw Console running at http://127.0.0.1:8088/
Open http://localhost:8088 to access the QwenPaw web console.
5.4 Make QwenPaw Persistent (LaunchDaemon)
Because QwenPaw is the service you'll rely on most for remote access, we install it as a LaunchDaemon. This means it starts at boot, before you log in, and doesn't depend on the desktop GUI starting successfully.
We also pin QwenPaw's internal log rotation to 2 MiB × 2 backups via EnvironmentVariables so the log directory can never exceed ~6 MiB.
Copy and paste the entire block. It dynamically pulls your current username and home directory to avoid placeholder errors:
USER_NAME=$(whoami)
HOME_DIR=$HOME
sudo tee /Library/LaunchDaemons/com.qwenpaw.app.plist > /dev/null << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.qwenpaw.app</string>
<key>UserName</key>
<string>${USER_NAME}</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>${HOME_DIR}/.qwenpaw/bin/qwenpaw</string>
<string>app</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>${HOME_DIR}</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>${HOME_DIR}</string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${HOME_DIR}/.local/bin</string>
<key>QWENPAW_LOG_MAX_SIZE</key>
<string>2MiB</string>
<key>QWENPAW_LOG_MAX_BACKUPS</key>
<string>2</string>
</dict>
<key>StandardOutPath</key>
<string>/tmp/qwenpaw.out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/qwenpaw.err.log</string>
</dict>
</plist>
EOF
sudo launchctl bootout system/com.qwenpaw.app 2>/dev/null
# Wait for the previous instance to fully unload before reloading
for _ in 1 2 3 4 5; do
sudo launchctl list 2>/dev/null | grep -q "com.qwenpaw.app" || break
sleep 1
done
sudo launchctl bootstrap system /Library/LaunchDaemons/com.qwenpaw.app.plist
sleep 5
sudo launchctl list | grep qwenpaw
Expected output:
12345 0 com.qwenpaw.app
The first column is the PID (a number means it's running), the second is the last exit status (0 = clean), and the third is the label.
Useful launcher management commands:
sudo launchctl list | grep qwenpaw # check status
sudo launchctl bootout system/com.qwenpaw.app # stop and unregister
sudo launchctl bootstrap system /Library/LaunchDaemons/com.qwenpaw.app.plist # start and register
sudo launchctl kickstart -k system/com.qwenpaw.app # restart in place
After editing the plist, you must
bootoutthenbootstrapfor changes to take effect — launchd caches the plist at load time. Add the polling loop above between the two commands to avoid theBootstrap failed: 5race on heavy daemons.
Part 6: Does Everything Survive a Reboot?
Restart your Mac:
sudo reboot
After reboot, wait 30 seconds, then SSH in from another machine:
ssh your-username@your-mac-ip
Check all services in one command:
API_KEY=$(jq -r '.auth.api_key' ~/.omlx/settings.json)
sudo launchctl list | grep -E "caddy|omlx|qwenpaw" && curl -s -H "Authorization: Bearer $API_KEY" http://localhost:8000/v1/models && curl -s -o /dev/null -w "QwenPaw HTTP %{http_code}\n" http://localhost:8088/
Expected output:
12345 0 com.caddy.server
12345 0 com.omlx.server
12345 0 com.qwenpaw.app
{"object":"list","data":[...]}
QwenPaw HTTP 200
All services should return healthy responses without any manual intervention.
Part 7: How Do You Access the Server from Anywhere?
This part sets up secure access to both oMLX and QwenPaw from anywhere. Tailscale provides encrypted SSH access to your Mac; Cloudflare Tunnel provides public HTTPS via your own domain. Caddy runs locally as a reverse proxy in front of both services.
7.0 Create a Tailscale Account
If you don't already have a Tailscale account, sign up first. It's free for personal use and takes about a minute.
- Go to tailscale.com and click Get Started.
- Sign up using a single sign-on (SSO) identity provider — Google, GitHub, Microsoft, Apple, or a custom email address.
- After signing in, choose Personal use.
- You land on the Admin Console at console.tailscale.com/admin.
Tip: The same account must be used on every device you want on your tailnet.
7.1 Install Tailscale on Your Mac Server
brew install --cask tailscale
Expected output: tailscale-app was successfully installed!
Open the Tailscale app from your Applications folder or menu bar, and sign in with the same account you just created. Once authenticated, the Tailscale icon appears in your menu bar and shows a green "Connected" status.
Note: The
--caskversion installs the GUI app but does not add thetailscaleCLI to your$PATH. See §7.1b below to enable it.
7.1b Enable the Tailscale CLI
The cask bundles the CLI inside the app binary. Do not symlink the app binary — it crashes with Fatal error: The current bundleIdentifier is unknown to the registry. Instead, add a shell alias:
echo 'alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"' >> ~/.zshrc && source ~/.zshrc && tailscale status
Expected output:
100.x.x.x my-mac-mini [email protected] macOS -
100.x.x.x my-laptop [email protected] macOS -
7.2 SSH Config for Tailnet Access (No MagicDNS Required)
MagicDNS is convenient but it isn't always compatible with other DNS setups on your Mac — particularly when Cloudflare is managing a public domain. The fix is a per-client SSH config file.
Get the Tailscale IP first (from the server or any tailnet device):
tailscale status | grep night-thoughts | awk '{print $1}'
Expected output: Something like 100.64.x.x — the Tailscale IP of your Mac server.
Then, on every client device you SSH from (not the server itself), append the alias to ~/.ssh/config:
mkdir -p ~/.ssh && cat >> ~/.ssh/config << 'EOF'
Host nt
HostName 100.64.x.x
User your-macos-username
EOF
Replace:
100.64.x.xwith the actual Tailscale IP from aboveyour-macos-usernamewith the account you log in as on the Mac server
Verify:
ssh nt
Why not
/etc/hosts? It requiressudo, breaks on OS updates that re-generate the file, and is global to the machine.~/.ssh/configis scoped to SSH, requires no elevated privileges, and survives system updates.
7.2b Remote Desktop Access via Tailscale (Screen Sharing)
While SSH gives you terminal access, sometimes you need to see the actual macOS desktop—to configure a GUI app, troubleshoot a display issue, or use the Admin Dashboard. macOS has a built-in VNC server (Screen Sharing), and Tailscale provides the secure tunnel to reach it from anywhere without exposing port 5900 to the public internet.
Step 1: Enable Screen Sharing on the Mac mini
- On the Mac mini, open System Settings → General → Sharing.
- Toggle Screen Sharing to ON.
- Click the (i) icon next to Screen Sharing.
- Ensure "VNC viewers may control screen with password" is checked, and set a strong password. (You will need this password for Windows/Linux clients).
- Note the Local hostname displayed at the top of the Sharing menu (e.g.,
night-thoughts.local).
Step 2: Connect from macOS (Native)
If you are connecting from another Mac on your tailnet, Apple's built-in Screen Sharing app is all you need.
Option A: From Finder
- Press
Cmd + Kto open "Connect to Server". - Enter your Mac mini's Tailscale IP:
vnc://100.x.y.z(replace with your actual Tailscale IP fromtailscale status). - If you have MagicDNS enabled, you can use the hostname instead:
vnc://night-thoughts.<your-tailnet>.ts.net. - Click Connect and enter your macOS login credentials.
Option B: From Terminal
open "vnc://100.x.y.z"
Step 3: Connect from Windows
Windows does not have a built-in VNC client, so you need to install one. RealVNC Viewer is the most reliable choice.
- Download and install RealVNC Viewer from the official website.
- Open RealVNC Viewer and click File → New connection.
- In the VNC Server field, enter your Mac mini's Tailscale IP:
100.x.y.z:5900(the:5900is the default VNC port). - Give the connection a friendly name (e.g., "Mac Mini").
- Double-click the connection. When prompted, enter the VNC password you set in Step 1.
Step 4: Connect from Linux
Linux users can use RealVNC Viewer (same as Windows) or Remmina (a popular open-source remote desktop client).
Using Remmina:
- Install Remmina via your package manager (e.g.,
sudo apt install remmina remmina-plugin-vnc). - Open Remmina and click the + button to create a new profile.
- Set Protocol to
VNC - Virtual Network Computing. - In the Server field, enter
100.x.y.z:5900. - Enter your VNC password and click Save and Connect.
⚠️ Headless Mac mini Note
If your Mac mini has no physical monitor attached, macOS may not generate a virtual display, resulting in a black screen when you connect. To fix this, plug a cheap HDMI dummy plug (headless display emulator) into the Mac mini's HDMI port. This tricks macOS into thinking a monitor is attached, forcing it to render the desktop for Screen Sharing.
Security Note: VNC traffic itself is not encrypted. However, because both machines are on your Tailscale tailnet, the entire session is wrapped inside the WireGuard tunnel. The connection is safe, and no ports are exposed to the public internet.
7.3 Optional: Enable HTTPS Certificates
When you need this. Only if you plan to enable §7.7 (
tailscale serve --https=443), which gives HTTPS access to your services over the tailnet. If you plan to use SSH-only access — authenticating as your Mac user and runningcurlon the Mac's loopback — skip this section. The commands here are for readers who want HTTPS-over-Tailscale as a convenience.
Tailscale Serve needs HTTPS certificates enabled for your tailnet before it can terminate TLS on port 443.
- Go to the DNS page of the Tailscale admin console.
- Under the HTTPS Certificates section, click Enable HTTPS.
If you enable this and later disable
tailscale serve, the certificates become inert. You can leave them enabled (harmless) or disable them on the same DNS page. They only matter if aserve --httpsorfunnelrule exists.
7.4 Install Caddy
Caddy is the always-on reverse proxy that routes each service and provides a single entry point. Install it via Homebrew:
brew install caddy
Expected output: caddy was successfully installed!
Verify:
caddy version
Expected output: v2.x.x
7.5 Configure Caddy
Caddy handles two routing modes at once:
- Subdomain routing for Cloudflare —
omlx.nightthoughts.devandqwenpaw.nightthoughts.deveach map to their service at the root. - Path routing for Tailscale Serve (only if you enable §7.7) — a single hostname (
night-thoughts.<your-tailnet>.ts.net) with/omlx/*and/console/*prefixes.
sudo mkdir -p /opt/homebrew/etc && sudo tee /opt/homebrew/etc/Caddyfile > /dev/null << 'EOF'
# ── Cloudflare subdomains (plain HTTP, tunnel forwards here) ──
http://omlx.nightthoughts.dev:9080 {
# Paths oMLX actually owns — pass through to the backend
@known path /admin /admin/* /v1 /v1/* /static/* /health /favicon.ico
handle @known {
reverse_proxy localhost:8000
}
# Root and any unmatched path → redirect to the dashboard
handle {
redir * /admin 302
}
}
http://qwenpaw.nightthoughts.dev:9080 {
reverse_proxy localhost:8088
}
# ── Tailscale Serve target (path-based, single hostname) ──────
# NOTE: This block is only used if you enable §7.7 (Tailscale Serve).
# If you're using SSH-only access, this block is dead code — you can
# safely remove it.
:9080 {
# oMLX entry point
@omlx_bare path /omlx
redir @omlx_bare /omlx/admin 302
handle_path /omlx/* {
reverse_proxy localhost:8000
}
# oMLX absolute paths (dashboard + assets + API)
@omlx_absolute path /admin /admin/* /static/* /v1 /v1/* /health
handle @omlx_absolute {
reverse_proxy localhost:8000
}
# QwenPaw: full console + backend
@qwenpaw path /console/* /api/* /assets/* /login /logout /voice/* /favicon.ico
handle @qwenpaw {
reverse_proxy localhost:8088
}
# QwenPaw: public files (SVG, PNG) at root
@qwenpaw_public path_regexp \.(svg|png|ico|gif|jpg|jpeg|webp|woff|woff2|ttf|eot)$
handle @qwenpaw_public {
reverse_proxy localhost:8088
}
# Fallback: oMLX
handle {
reverse_proxy localhost:8000
}
}
EOF
Why both blocks? The subdomain blocks (
http://omlx.nightthoughts.dev:9080) only match requests where theHostheader is that subdomain — which is what Cloudflare sends. The:9080block catches everything else, which is what Tailscale Serve sends.
The
:9080block is conditional. Its only purpose is to servetailscale servein §7.7. If you skip §7.7 (SSH-only), this block receives no traffic — the two subdomain blocks alone handle Cloudflare. Keeping it is harmless; removing it is cleaner if you know you're going SSH-only.
Why
http://on the subdomains? Without it, Caddy would try to provision its own TLS certificate foromlx.nightthoughts.dev, which fails because Cloudflare already holds one for that hostname and Caddy can't complete the ACME challenge. Thehttp://prefix tells Caddy to serve that hostname over plain HTTP only.
The
*matcher inredir * /admin 302is essential. Caddy'sredirdirective is ambiguous when the destination starts with/: without an explicit matcher, Caddy can interpret/adminas a path matcher rather than the destination.
Verify the syntax:
caddy validate --config /opt/homebrew/etc/Caddyfile
Expected output: Valid configuration
7.6 Start Caddy as an Always-On Service
To ensure Caddy starts at boot—even if the desktop session fails to load—we will run it as a LaunchDaemon. Just like we did for oMLX, we stop the Homebrew service, remove its plist, and create our own system-level daemon.
First, completely remove the old Homebrew LaunchAgent to prevent port conflicts:
brew services stop caddy 2>/dev/null
launchctl bootout gui/$(id -u)/homebrew.mxcl.caddy 2>/dev/null
rm -f ~/Library/LaunchAgents/homebrew.mxcl.caddy.plist
Now create the LaunchDaemon:
USER_NAME=$(whoami)
HOME_DIR=$HOME
sudo tee /Library/LaunchDaemons/com.caddy.server.plist > /dev/null << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.caddy.server</string>
<key>UserName</key>
<string>${USER_NAME}</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/caddy</string>
<string>run</string>
<string>--config</string>
<string>/opt/homebrew/etc/Caddyfile</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>${HOME_DIR}</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>${HOME_DIR}</string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${HOME_DIR}/.local/bin</string>
</dict>
<key>StandardOutPath</key>
<string>/tmp/caddy.out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/caddy.err.log</string>
</dict>
</plist>
EOF
sudo launchctl bootout system/com.caddy.server 2>/dev/null
# Wait for the previous instance to fully unload before reloading
for _ in 1 2 3 4 5; do
sudo launchctl list 2>/dev/null | grep -q "com.caddy.server" || break
sleep 1
done
sudo launchctl bootstrap system /Library/LaunchDaemons/com.caddy.server.plist
sleep 3
sudo launchctl list | grep caddy
Expected output:
12345 0 com.caddy.server
Verify the migration actually landed:
brew services list | grep -i caddy && echo "⚠️ brew still tracks caddy" || echo "✅ brew no longer tracks caddy"
[ -f ~/Library/LaunchAgents/homebrew.mxcl.caddy.plist ] && echo "⚠️ legacy plist still exists" || echo "✅ legacy plist removed"
sudo launchctl list | grep -q "com.caddy.server" && echo "✅ com.caddy.server loaded" || echo "❌ com.caddy.server NOT loaded"
Confirm it's listening on port 9080:
lsof -nP -iTCP:9080 -sTCP:LISTEN | tail -1
Expected output:
caddy 12345 yourname ... TCP *:9080 (LISTEN)
After editing the Caddyfile, you must reload Caddy with
sudo launchctl kickstart -k system/com.caddy.server. Thekickstart -krestarts the process with the new config file — you do not needbootout+bootstraphere because only an external file (the Caddyfile) changed, not the plist.If
bootstrapfails with5: Input/output error: same race as §4.4 — wait 3 seconds and re-run thebootstrapline, or re-run the whole block (the polling loop will handle it).
7.6b Upgrading Caddy Later (Homebrew + LaunchDaemon Notice)
Caddy is installed via Homebrew but runs under our custom LaunchDaemon (com.caddy.server), not under brew services. This has an important consequence you must remember every time you upgrade it.
brew upgrade caddy does three things:
- It downloads and installs the new Caddy release into
/opt/homebrew/Cellar/caddy/<new-version>/. - It atomically repoints the stable symlink
/opt/homebrew/bin/caddyto the new version. - It does not restart your custom LaunchDaemon, and it does not touch
/Library/LaunchDaemons/com.caddy.server.plist.
So immediately after brew upgrade caddy finishes, the following is true:
sudo launchctl list | grep caddystill showscom.caddy.serverrunning.- Your sites (
omlx.nightthoughts.dev,qwenpaw.nightthoughts.dev, Tailscale Serve) continue to serve traffic without interruption. - But the running process is still executing the old binary image from memory.
- The new version on disk is not in use until launchd restarts the process.
Because our plist points to the symlink /opt/homebrew/bin/caddy (not a versioned Cellar path), the upgrade itself is safe — it will not break the daemon on next start. But you must manually restart the daemon for the new version to actually run.
Unlike oMLX, Caddy has one extra risk: a new major/minor release may reject Caddyfile syntax that the previous version accepted. Always validate the config before restarting the daemon.
After every brew upgrade caddy, run:
caddy validate --config /opt/homebrew/etc/Caddyfile
sudo launchctl kickstart -k system/com.caddy.server
Then verify that the daemon came back up, is listening on port 9080, and is serving traffic:
sudo launchctl list | grep caddy
lsof -i :9080 | grep caddy
tail -20 /tmp/caddy.err.log
curl -s -o /dev/null -w "Local → HTTP %{http_code}\n" http://localhost:9080/
The expected output:
launchctl listshowscom.caddy.serverwith a PID and exit code0.lsofshows Caddy listening on*:9080.- The error log contains no
loading Caddyfileerrors. - The local
curlreturns a non-502status (typically302for the oMLX redirect, or200for a proxied request).
Do not use brew services restart caddy. You removed the Homebrew-managed service in §7.6 on purpose. Using brew services would recreate its own plist, reintroduce port conflicts on 9080, and potentially overwrite your Caddyfile configuration path.
If you prefer to combine validation, upgrade, and restart in one chain:
caddy validate --config /opt/homebrew/etc/Caddyfile \
&& brew upgrade caddy \
&& caddy validate --config /opt/homebrew/etc/Caddyfile \
&& sudo launchctl kickstart -k system/com.caddy.server
The first validate runs against the currently installed version, so if the existing config is already broken you catch that before you touch the package. The second validate runs against the newly installed version.
A full reboot also loads the new version (because launchd re-reads the plist and resolves the symlink at boot), but a kickstart is faster and lets you inspect logs immediately.
7.7 Optional: Point Tailscale Serve at Caddy (Convenience — Bypasses Auth)
Security note. This step gives you HTTPS access to your services over your tailnet by bypassing Caddy entirely. Anyone on your tailnet — verified at the WireGuard layer, not by any password — can reach
https://<hostname>.<tailnet>.ts.net/without going through Caddy'sbasicauthor the upstream service's own auth. This is fine if your tailnet contains only devices you personally own. If your tailnet contains shared devices, family machines, or other users, skip this section and usessh nt 'curl http://127.0.0.1:...'to reach services instead.DNS note. Some users have seen MagicDNS conflict with Cloudflare-managed DNS on the local machine —
digresolves fine butcurlreturnsCould not resolve host. If that happens, runtailscale set --accept-dns=falseand flush the resolver:tailscale set --accept-dns=false sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderIf you enable this step now and decide to go SSH-only later, disable it with
tailscale serve resetand remove the:9080block from the Caddyfile (§7.5).
Tailscale Serve exposes your services to devices on your tailnet — encrypted, private, and without requiring a public domain.
tailscale serve reset
tailscale serve --bg --https=443 http://localhost:9080
Verify:
tailscale serve status
Expected output:
https://night-thoughts.<your-tailnet>.ts.net (tailnet only)
|-- / proxy http://localhost:9080
Important — Tailscale DNS hijack: If
digresolves your Cloudflare subdomains butcurlfrom the server returnsCould not resolve host, Tailscale's MagicDNS resolver is capturing all system DNS queries. Fix it with:tailscale set --accept-dns=false sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
7.8 Enable QwenPaw Authentication
Tailscale controls network-level access, but anyone on your tailnet — and anyone on the internet once §7.9 is set up — can reach QwenPaw. Enabling QwenPaw's built-in web authentication adds a login prompt.
Rewrite the plist with the auth variables added, then reload the service. Replace your-secure-password with a strong password of your choice:
USER_NAME=$(whoami)
HOME_DIR=$HOME
sudo launchctl bootout system/com.qwenpaw.app 2>/dev/null
# Wait for the previous instance to fully unload before reloading
for _ in 1 2 3 4 5; do
sudo launchctl list 2>/dev/null | grep -q "com.qwenpaw.app" || break
sleep 1
done
sudo tee /Library/LaunchDaemons/com.qwenpaw.app.plist > /dev/null << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.qwenpaw.app</string>
<key>UserName</key>
<string>${USER_NAME}</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>${HOME_DIR}/.qwenpaw/bin/qwenpaw</string>
<string>app</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>${HOME_DIR}</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>${HOME_DIR}</string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${HOME_DIR}/.local/bin</string>
<key>QWENPAW_LOG_MAX_SIZE</key>
<string>2MiB</string>
<key>QWENPAW_LOG_MAX_BACKUPS</key>
<string>2</string>
<key>QWENPAW_AUTH_ENABLED</key>
<string>true</string>
<key>QWENPAW_AUTH_USERNAME</key>
<string>admin</string>
<key>QWENPAW_AUTH_PASSWORD</key>
<string>your-secure-password</string>
</dict>
<key>StandardOutPath</key>
<string>/tmp/qwenpaw.out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/qwenpaw.err.log</string>
</dict>
</plist>
EOF
sudo launchctl bootstrap system /Library/LaunchDaemons/com.qwenpaw.app.plist
sleep 3
sudo launchctl list | grep qwenpaw
Expected output:
12345 0 com.qwenpaw.app
Verify auth is active by checking that the console redirects to a login page:
curl -s -o /dev/null -w "QwenPaw HTTP %{http_code}\n" http://localhost:8088/
Expected output:
QwenPaw HTTP 200
Forgot the password? Reset it with:
QWENPAW_AUTH_ENABLED=true qwenpaw auth reset-password
7.9 Public Access with Subdomains
This section extends your setup from tailnet-only access to the public internet. After completing these steps, your services become reachable from any browser — no Tailscale client required — using subdomains on your own domain.
The result:
| Service | Public URL |
|---|---|
| oMLX admin dashboard | https://omlx.nightthoughts.dev/admin |
| oMLX API | https://omlx.nightthoughts.dev/v1/models |
| QwenPaw web console | https://qwenpaw.nightthoughts.dev/ |
Security warning: These URLs are reachable by anyone on the internet. You must have authentication enabled on both services before exposing them publicly.
Step 1: Add your domain to Cloudflare
- Sign up at cloudflare.com (free tier is enough).
- Click Add a site and enter
nightthoughts.dev. - Choose the Free plan.
- Cloudflare will scan your existing DNS records and display two nameservers assigned to your account.
Step 2: Point the domain to Cloudflare at your registrar
Cloudflare needs to be the authoritative DNS provider for your domain. This means replacing your registrar's default nameservers with the two Cloudflare nameservers shown in Step 1.
The process is the same for every registrar:
- Log in to your registrar account and find the DNS or nameserver settings for
nightthoughts.dev. - Locate the current nameservers.
- Delete them.
- Paste the two Cloudflare nameservers.
- Save your changes.
Important: If DNSSEC is enabled at your registrar, disable it before changing nameservers. DNSSEC conflicts with the new authoritative DNS provider.
Verify propagation
After saving, check that the new nameservers are live:
dig +short NS nightthoughts.dev @1.1.1.1
Expected output:
april.ns.cloudflare.com.
damien.ns.cloudflare.com.
Step 3: Install cloudflared
brew install cloudflared
Step 4: Authenticate
cloudflared tunnel login
This opens a browser — select nightthoughts.dev and authorize.
Step 5: Create the tunnel
cloudflared tunnel list | grep -q night-thoughts || cloudflared tunnel create night-thoughts
Step 6: Route DNS for both subdomains
cloudflared tunnel route dns night-thoughts omlx.nightthoughts.dev
cloudflared tunnel route dns night-thoughts qwenpaw.nightthoughts.dev
Each command creates a proxied CNAME at Cloudflare pointing the subdomain to your tunnel.
Step 7: Configure the tunnel
TUNNEL_ID=$(cloudflared tunnel list | awk '/night-thoughts/ {print $1}') && \
cat > ~/.cloudflared/config.yml << EOF
tunnel: $TUNNEL_ID
credentials-file: $HOME/.cloudflared/$TUNNEL_ID.json
ingress:
- hostname: omlx.nightthoughts.dev
service: http://localhost:9080
- hostname: qwenpaw.nightthoughts.dev
service: http://localhost:9080
- service: http_status:404
EOF
Step 8: Install the tunnel as a LaunchDaemon
Do not use
sudo cloudflared service installon macOS. It writes a broken launchd plist that omits thetunnel runsubcommand, so the daemon exits immediately withuse cloudflared tunnel run to start tunnel <UUID>in a loop.
Just like QwenPaw, cloudflared should be a LaunchDaemon so it starts at boot, before login. This block dynamically injects your username and home path. It also sets WorkingDirectory and EnvironmentVariables to match the other three LaunchDaemons in this guide — HOME makes the ~/.cloudflared/config.yml resolution deterministic (Go's os.UserHomeDir() falls back to getpwuid when $HOME is unset, but making it explicit removes the ambiguity), and PATH is included for consistency with the omlx / qwenpaw / caddy plists even though cloudflared doesn't spawn subprocesses:
USER_NAME=$(whoami)
HOME_DIR=$HOME
sudo tee /Library/LaunchDaemons/com.cloudflare.cloudflared.plist > /dev/null << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.cloudflare.cloudflared</string>
<key>UserName</key>
<string>${USER_NAME}</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/cloudflared</string>
<string>tunnel</string>
<string>run</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>${HOME_DIR}</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>${HOME_DIR}</string>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${HOME_DIR}/.local/bin</string>
</dict>
<key>StandardOutPath</key>
<string>/tmp/cloudflared.out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/cloudflared.err.log</string>
</dict>
</plist>
EOF
sudo launchctl bootout system/com.cloudflare.cloudflared 2>/dev/null
# Wait for the previous instance to fully unload before reloading
for _ in 1 2 3 4 5; do
sudo launchctl list 2>/dev/null | grep -q "com.cloudflare.cloudflared" || break
sleep 1
done
sudo launchctl bootstrap system /Library/LaunchDaemons/com.cloudflare.cloudflared.plist
sleep 5
sudo launchctl list | grep cloudflared
Expected output:
12345 0 com.cloudflare.cloudflared
Already running an older cloudflared plist? If you ran Part 0 before this version, your existing plist lacks
WorkingDirectoryandEnvironmentVariables. Thebootout+bootstrapabove replaces it wholesale — theteeoverwrites the file, then launchd re-reads it. Confirm withsudo plutil -p /Library/LaunchDaemons/com.cloudflare.cloudflared.plist | grep -A2 WorkingDirectory— you should see"/Users/<you>". If it's missing, theteefailed (usually a permissions issue; re-run with thesudoat the start).
Step 8b: Upgrading cloudflared Later (Homebrew + LaunchDaemon Notice)
cloudflared is installed via Homebrew but runs under our custom LaunchDaemon (com.cloudflare.cloudflared), not under brew services (which is not used for it in this guide at all). This has an important consequence you must remember every time you upgrade it.
brew upgrade cloudflared does three things:
- It downloads and installs the new cloudflared release into
/opt/homebrew/Cellar/cloudflared/<new-version>/. - It atomically repoints the stable symlink
/opt/homebrew/bin/cloudflaredto the new version. - It does not restart your custom LaunchDaemon, and it does not touch
/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.
So immediately after brew upgrade cloudflared finishes, the following is true:
sudo launchctl list | grep cloudflaredstill showscom.cloudflare.cloudflaredrunning.- Your public tunnels for
omlx.nightthoughts.devandqwenpaw.nightthoughts.devcontinue to work. - But the running process is still executing the old binary image from memory.
- The new version on disk is not in use until launchd restarts the process.
Because our plist points to the symlink /opt/homebrew/bin/cloudflared (not a versioned Cellar path), the upgrade itself is safe — it will not break the tunnel on next start. But you must manually restart the daemon for the new version to actually run.
After every brew upgrade cloudflared, run:
sudo launchctl kickstart -k system/com.cloudflare.cloudflared
Then verify that the daemon came back up and that both tunnel connections re-registered:
sudo launchctl list | grep cloudflared
sleep 10
tail -30 /tmp/cloudflared.err.log
The expected output:
launchctl listshowscom.cloudflare.cloudflaredwith a PID and exit code0.- The log shows a fresh health precheck and at least two
Registered tunnel connection connIndex=...lines (typicallyconnIndex=0andconnIndex=1). - No repeating
use cloudflared tunnel run to start tunnel <UUID>loop, and nofailed to connecterrors.
Do not use sudo cloudflared service install. As noted in Step 8, it writes a broken macOS plist that omits the tunnel run subcommand. Sticking with your custom LaunchDaemon is the correct upgrade path.
If you prefer to combine upgrade and restart in one command:
brew upgrade cloudflared && sudo launchctl kickstart -k system/com.cloudflare.cloudflared
A full reboot also loads the new version (because launchd re-reads the plist and resolves the symlink at boot), but a kickstart is faster and lets you inspect tunnel logs immediately.
Step 9: Verify
Now check the log to confirm the tunnel is actually connected:
tail -20 /tmp/cloudflared.err.log
Expected output: A health precheck summary followed by connection logs:
INF | SUMMARY: Environment is healthy. cloudflared will use 'quic' as primary protocol. |
INF precheck complete hard_fail=false run_id=... suggested_protocol=quic
INF Registered tunnel connection connIndex=0 connection=... location=hkg
INF Registered tunnel connection connIndex=1 connection=... location=hkg
Then test publicly. The first test checks that unmatched paths redirect properly:
curl -sL -o /dev/null -w "/typo → %{http_code} %{url_effective}\n" https://omlx.nightthoughts.dev/typo
curl -s -o /dev/null -w "/ → %{http_code}\n" https://omlx.nightthoughts.dev/
curl -s -o /dev/null -w "/admin → %{http_code}\n" https://omlx.nightthoughts.dev/admin
curl -s -o /dev/null -w "/v1/models → %{http_code}\n" https://omlx.nightthoughts.dev/v1/models
curl -s -o /dev/null -w "QwenPaw / → %{http_code}\n" https://qwenpaw.nightthoughts.dev/
Expected output:
/typo → 200 https://omlx.nightthoughts.dev/admin
/ → 302
/admin → 200
/v1/models → 401 (no key sent)
QwenPaw / → 200
Useful commands:
# Check tunnel status
sudo launchctl list | grep cloudflared
# View cloudflared logs
tail -20 /tmp/cloudflared.err.log
# Restart the tunnel after config changes
sudo launchctl kickstart -k system/com.cloudflare.cloudflared
# Remove the tunnel entirely
sudo launchctl bootout system/com.cloudflare.cloudflared
sudo rm /Library/LaunchDaemons/com.cloudflare.cloudflared.plist
cloudflared tunnel delete night-thoughts
7.10 Verify Everything Survives Reboot
Restart your Mac:
sudo reboot
After reboot, wait 30 seconds, then SSH in from another machine:
ssh nt
Check all services in one command:
sudo launchctl list | grep -E "caddy|omlx|qwenpaw|cloudflared" && tailscale serve status
Expected output:
12345 0 com.caddy.server
12345 0 com.omlx.server
12345 0 com.qwenpaw.app
12345 0 com.cloudflare.cloudflared
https://night-thoughts.<your-tailnet>.ts.net (tailnet only)
|-- / proxy http://localhost:9080
If you skipped §7.7 (SSH-only),
tailscale serve statuswill print nothing. That's expected. Verify SSH-only access instead:ssh nt 'curl -s -o /dev/null -w "oMLX: %{http_code}\n" http://127.0.0.1:8000/v1/models'
All components should be running without any manual intervention:
| Component | Managed by | Domain | Auto-starts on login? | Auto-starts at boot? |
|---|---|---|---|---|
| oMLX | launchd |
System | ✅ | ✅ |
| Caddy | launchd |
System | ✅ | ✅ |
| QwenPaw | launchd |
System | ✅ | ✅ |
| cloudflared | launchd |
System | ✅ | ✅ |
| Tailscale Serve (§7.7 only) | Tailscale daemon | System | ✅ | ✅ |
Then verify public access works end-to-end:
curl -s -o /dev/null -w "Public oMLX: HTTP %{http_code}\n" https://omlx.nightthoughts.dev/admin
curl -s -o /dev/null -w "Public QwenPaw: HTTP %{http_code}\n" https://qwenpaw.nightthoughts.dev/
Troubleshooting Quick Reference
| Symptom | Fix |
|---|---|
systemsetup: Turning Remote Login on or off requires Full Disk Access privileges |
Grant Terminal Full Disk Access in System Settings → Privacy & Security → Full Disk Access, then quit and reopen Terminal |
pmset -g shows SleepDisabled 1 instead of disablesleep 1 |
Normal on macOS Ventura+. Same setting, different label |
sleep 0 (sleep prevented by powerd, bluetoothd) |
Informational, not an error. Sleep is disabled as intended |
| Services respond slowly or hang under load | App Nap is throttling them. Verify caffeinate is running: `launchctl list |
| Services don't start after reboot | The GUI session didn't load. All services (oMLX, Caddy, QwenPaw, cloudflared) will still start because they are LaunchDaemons. See §1.4 for diagnosis |
Could not find service "com.qwenpaw.app" in domain for user gui: 501 |
QwenPaw is a LaunchDaemon. Use sudo launchctl kickstart -k system/com.qwenpaw.app instead of the gui/ domain. See §1.4 |
Could not find service "com.caddy.server" in domain for user gui: 501 |
Caddy is a LaunchDaemon. Use sudo launchctl kickstart -k system/com.caddy.server instead of the gui/ domain. |
brew: command not found |
Run eval "$(/opt/homebrew/bin/brew shellenv)" or add it to ~/.zprofile |
jq: command not found or yq: command not found |
Run brew install jq yq (see §4.1b). Both are installed early because later steps depend on them. |
Error: Refusing to load formula ... from untrusted tap |
Run brew trust jundot/omlx, then retry brew install jundot/omlx/omlx |
| oMLX install rejected on Intel Mac or macOS 14 | oMLX requires Apple Silicon and macOS 15.0 (Sequoia) or later |
AttributeError: module 'mlx' has no attribute '__version__' |
Expected — version lives on mlx.core. Use python -c "import mlx.core as mx; print(mx.__version__)" |
Admin dashboard shows 404 at localhost:8000 |
The correct path is /admin, not /. |
omlx.nightthoughts.dev/typo returns a blank page instead of redirecting to /admin |
The redir directive is missing its * matcher. Change redir /admin 302 to redir * /admin 302 in the oMLX subdomain block |
401 Unauthorized from oMLX |
The api_key in QwenPaw's config doesn't match the key in ~/.omlx/settings.json. Both must be exactly the same string |
| Need to change the oMLX API key | Re-run the generation block in §4.3, then restart the daemon (sudo launchctl kickstart -k system/com.omlx.server) and update QwenPaw |
Bootstrap failed: 5: Input/output error after bootout |
The previous instance hasn't fully exited yet. The polling loop in §4.4/§5.4/§7.6/§7.8/§7.9 prevents this — if you hit it anyway, wait 3 seconds and re-run the bootstrap line |
lsof -i :8000 shows Python instead of omlx |
Normal — /opt/homebrew/bin/omlx is a Python shebang script, and lsof reports the kernel's process name. ps -p <PID> -o comm shows omlx-server. Same process, different tools, different names |
Upgraded Caddy via brew upgrade caddy but caddy version still shows the old version |
brew upgrade does not restart custom LaunchDaemons. Run sudo launchctl kickstart -k system/com.caddy.server. See §7.6b |
Upgraded oMLX via brew upgrade omlx but the running process is still the old version |
brew upgrade does not restart custom LaunchDaemons. Run sudo launchctl kickstart -k system/com.omlx.server. See §4.4b |
Upgraded cloudflared via brew upgrade cloudflared but the tunnel is still the old version |
brew upgrade does not restart custom LaunchDaemons. Run sudo launchctl kickstart -k system/com.cloudflare.cloudflared. See §7.9 Step 8b |
brew services restart caddy / brew services restart omlx breaks the service or creates a duplicate plist |
Do not use brew services for Caddy or oMLX. They are managed by custom LaunchDaemons. Use sudo launchctl kickstart -k system/com.<service> instead |
| Forgot the QwenPaw password | Run QWENPAW_AUTH_ENABLED=true qwenpaw auth reset-password, or delete ~/.qwenpaw.secret/auth.json and restart the daemon |
| QwenPaw login fails with "Invalid credentials" | The username in auth.json doesn't match the plist. Check cat ~/.qwenpaw.secret/auth.json — if it says night-thoughts but you're typing admin, either log in as night-thoughts or delete the file and restart to regenerate it from the plist |
QwenPaw daemon exits with code 78 (EX_CONFIG) |
A placeholder value was left in the plist. Check with sudo plutil -p /Library/LaunchDaemons/com.qwenpaw.app.plist and fix UserName and WorkingDirectory |
Telegram: Conflict: terminated by other getUpdates request |
Two QwenPaw instances are polling the same bot token. Kill the duplicate with sudo pkill -9 -f qwenpaw, remove ~/.qwenpaw/desktop_backend.pid, and revoke the token via @BotFather |
Telegram: invalid bot token — not retrying |
The token was revoked. Get a fresh one from @BotFather and paste it into the QwenPaw console at Channels → Telegram |
cloudflared tunnel route dns says "neither the ID nor the name of any of your tunnels" |
Run cloudflared tunnel list to see actual tunnel names, then retry with the exact name or ID |
cloudflared log spams use cloudflared tunnel run to start tunnel <UUID> |
sudo cloudflared service install wrote a broken plist. Use the LaunchDaemon block in §7.9 Step 8 instead |
| Nameserver change at your registrar isn't propagating | Confirm DNSSEC is disabled at your registrar. Check status with dig +short NS <domain> @1.1.1.1 |
dig works but curl returns Could not resolve host |
Tailscale MagicDNS is hijacking the system resolver. Run tailscale set --accept-dns=false then sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
ssh nt returns Could not resolve hostname |
Your ~/.ssh/config entry is missing or malformed |
ssh nt returns Permission denied |
Wrong username in ~/.ssh/config. Verify with whoami on the server |
tailscale serve status still shows a rule after tailscale serve reset |
Same-user identity mismatch, or a second tailscale serve process added a new rule. Re-run tailscale serve reset, then `tailscale debug prefs |
Decided to go SSH-only and want to remove the Caddy :9080 block |
The block is only used by tailscale serve (§7.7). After tailscale serve reset, remove the block from /opt/homebrew/etc/Caddyfile, validate with caddy validate --config /opt/homebrew/etc/Caddyfile, then sudo launchctl kickstart -k system/com.caddy.server |
If you build this stack, tag me — I want to see what agents and local workflows you are running on your Mac. And if you are working on local LLM inference, Apple Silicon optimization, or self-hosted AI, let us talk in the comments or connect directly.
— Haithem Slimi, nightthoughts.me (blog) · nightthoughts.dev (work)
FAQ
Which Macs can run this setup?
Apple Silicon Macs (M1 to M5) on macOS 15 Sequoia or later. MLX and oMLX require Apple Silicon.
What do MLX, oMLX and QwenPaw each do?
MLX is Apple's machine-learning framework. oMLX is the inference server with an admin dashboard that serves local models. QwenPaw is the agent framework that runs on top of them.
Do the services come back after a reboot?
Yes. Part 6 reboots the Mac and checks every service over SSH from another machine.
How do I reach the server remotely and securely?
Tailscale gives you encrypted SSH access, Cloudflare Tunnel gives public HTTPS on your own domain, and Caddy runs locally as the reverse proxy in front of the services.
About the author
- Father of two, tech lover. Building systems by day, raising curious minds by night. I write hands-on guides and reproducible experiments on running, fine-tuning and evaluating AI locally on Apple Silicon, on AI agents, and on how AI changes software and finance. The code behind every experiment is on GitHub: github.com/hslimi/night-thoughts
Comments
Join the discussionNo comments yet. Be the first to comment.
Local AI Lab
A hands-on series about running AI yourself: local models, agents with boundaries, LLM routing, memory and always-on self-hosted servers, with zero cloud dependency.






