Fix OpenClaw Stops Responding After Turning Off Screen on Mac Mini

Prerequisites
Before starting, ensure you have:
- Mac Mini running macOS Sequoia or later (Apple Silicon preferred)
- Latest OpenClaw installed globally (
npm install -g openclaw@latest) - Gateway already running normally when screen is on (
openclaw gateway statusshows running) - Confirmed symptom: works perfectly → turn screen off (or let it sleep) → after 5–30 minutes, messages get no reply
- Terminal.app access and basic comfort with
pmset/caffeinate - Optional but highly recommended: Dummy HDMI dongle
Symptom details: Everything is normal with screen on. After turning off the display (or auto sleep), WebSocket/Gateway becomes unresponsive after a while — no thinking, no reply, logs show connection drops.
Step 1: Confirm the Exact Trigger with Logs
- Turn screen on, send a test message (“What time is it?”) — confirm it replies instantly.
- Turn screen off (or let it sleep).
- Wait 10–15 minutes, then send another test message.
- Immediately check logs while screen is still off:
openclaw logs --tail 100 | grep -i sleep\|websocket\|connection\|error
Look for clues like WebSocket closed, connection reset, energy saver, or Ollama timeout. This proves the issue is tied to display sleep / power management.
Step 2: Understand Why Screen Off Breaks OpenClaw
macOS aggressively enters low-power states when the display is off:
- Display sleep → Wi-Fi throttled or disconnected
- Background processes (Gateway, Ollama, browser skills) get suspended
- WebSocket connections drop silently
- Even LaunchAgent services can be affected if not marked “KeepAlive” + caffeinate wrapper
The fix is to prevent display sleep entirely while keeping the Mac Mini headless and energy-efficient.
Step 3: Disable Display Sleep Permanently (Core Fix)
Run these one-time commands (apply to all power sources):
sudo pmset -a displaysleep 0
sudo pmset -a sleep 0
sudo pmset -a hibernatemode 0
sudo pmset -a disablesleep 1
sudo pmset -a autorestart 1
Verify settings:
pmset -g
Expected output should show displaysleep: 0, sleep: 0, disablesleep: 1.
Reboot and test: turn screen off → wait 30+ minutes → ask a question. Most users see instant replies after this step alone.
Step 4: Add caffeinate Wrapper for Extra Protection
caffeinate keeps the system awake even if pmset is overridden.
Create a permanent wrapper in your LaunchAgent:
openclaw gateway install --daemon
Then edit ~/Library/LaunchAgents/ai.openclaw.gateway.plist and change the ProgramArguments section to:
<key>ProgramArguments</key>
<array>
<string>/usr/bin/caffeinate</string>
<string>-u</string>
<string>-t</string>
<string>0</string>
<string>/usr/local/bin/openclaw</string>
<string>gateway</string>
<string>start</string>
</array>
Reload:
launchctl unload ~/Library/LaunchAgents/ai.openclaw.gateway.plist
launchctl load ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Now the Gateway runs under caffeinate — screen off has zero effect.
Step 5: Add Dummy HDMI + Final Polish for True 24/7
- Insert a dummy HDMI plug into the Mac Mini (cheap on Amazon, ~$10). This tricks macOS into thinking a display is always connected.
- Confirm auto-login is enabled for the OpenClaw account (System Settings → Users & Groups → Login Options).
- Use wired Ethernet (or Tailscale) to avoid any Wi-Fi sleep behavior.
- Restart once and test: screen off for 1–2 hours → send messages → should respond immediately.
Common Issues & Troubleshooting
- Still no response after 30+ minutes → Run
pmset -gagain and confirmdisplaysleep 0; addcaffeinate -dimsu &manually in Terminal and re-test - Logs show “power nap” or “dark wake” →
sudo pmset -a powernap 0andsudo pmset -a standby 0 - LaunchAgent stops after reboot → Re-run
openclaw gateway install --daemonand checklaunchctl list | grep openclaw - Wi-Fi drops despite settings → Switch to Ethernet or install “Keep Wi-Fi Alive” app / Tailscale always-on
- Ollama specifically sleeps → Run Ollama under its own caffeinate:
caffeinate -u -t 0 ollama serve & - Full health check:
openclaw doctor --deep(run with screen off via SSH)
Next Steps
- Add watchdog skill to auto-restart Gateway if it ever goes silent
- Set up remote access via Tailscale so you can check
openclaw logswithout turning screen on - Configure multiple channels (Telegram + iMessage) for easy testing from phone
- Explore low-power mode tweaks for even better electricity bill
- Official daemon guide: https://docs.openclaw.ai/gateway/daemon
- Join Discord for Mac-specific tips: https://discord.gg/clawd
After these steps, your OpenClaw will stay fully responsive on Mac Mini even if the screen stays off for days — no more “问话没反应” after turning off the display.