Skip to content

How to Run OpenClaw.app with a Remote Gateway

Ever found yourself needing to run a local app while the actual engine is humming away on a remote server? It is a classic developer hurdle: you want the local UI experience but need the remote horsepower.

Setting up a stable connection between your machine and a remote gateway shouldn’t feel like a chore. This guide helps you bridge that gap using a simple SSH tunnel so you can get back to work.

This content has been merged into Remote Access. See that page for the current guide.

Running OpenClaw.app with a Remote Gateway

Section titled “Running OpenClaw.app with a Remote Gateway”

OpenClaw.app uses SSH tunneling to connect to a remote gateway. This guide shows you how to set it up.

flowchart TB
subgraph Client["Client Machine"]
direction TB
A["OpenClaw.app"]
B["ws://127.0.0.1:18789\n(local port)"]
T["SSH Tunnel"]
A --> B
B --> T
end
subgraph Remote["Remote Machine"]
direction TB
C["Gateway WebSocket"]
D["ws://127.0.0.1:18789"]
C --> D
end
T --> C

Edit ~/.ssh/config and add:

Terminal window
Host remote-gateway
HostName <REMOTE_IP> # e.g., 172.27.187.184
User <REMOTE_USER> # e.g., jefferson
LocalForward 18789 127.0.0.1:18789
IdentityFile ~/.ssh/id_rsa

Replace <REMOTE_IP> and <REMOTE_USER> with your values.

Copy your public key to the remote machine (enter password once):

Terminal window
ssh-copy-id -i ~/.ssh/id_rsa <REMOTE_USER>@<REMOTE_IP>
Terminal window
launchctl setenv OPENCLAW_GATEWAY_TOKEN "<your-token>"
Terminal window
ssh -N remote-gateway &
Terminal window
# Quit OpenClaw.app (⌘Q), then reopen:
open /path/to/OpenClaw.app

The app will now connect to the remote gateway through the SSH tunnel.


To have the SSH tunnel start automatically when you log in, create a Launch Agent.

Save this as ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist:

<?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>ai.openclaw.ssh-tunnel</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ssh</string>
<string>-N</string>
<string>remote-gateway</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Terminal window
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist

The tunnel will now:

  • Start automatically when you log in
  • Restart if it crashes
  • Keep running in the background
  • Maintain the connection without manual intervention

Legacy note: remove any leftover com.openclaw.ssh-tunnel LaunchAgent if present.


Check if tunnel is running:

Terminal window
ps aux | grep "ssh -N remote-gateway" | grep -v grep
lsof -i :18789

Restart the tunnel:

Terminal window
launchctl kickstart -k gui/$UID/ai.openclaw.ssh-tunnel

Stop the tunnel:

Terminal window
launchctl bootout gui/$UID/ai.openclaw.ssh-tunnel

ComponentWhat It Does
LocalForward 18789 127.0.0.1:18789Forwards local port 18789 to remote port 18789
ssh -NSSH without executing remote commands (just port forwarding)
KeepAliveAutomatically restarts tunnel if it crashes
RunAtLoadStarts tunnel when the agent loads

OpenClaw.app connects to ws://127.0.0.1:18789 on your client machine. The SSH tunnel forwards that connection to port 18789 on the remote machine where the Gateway is running.

  • Explore the Remote Access guide for more details.
  • Check out the Gateway configuration options.

Need more help? Try the AI Setup Assistant.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.