How to Run Multiple OpenClaw Gateways on a Single Host
I have often found myself in a situation where my main bot crashes or gets stuck, and I have no way to reach it to fix the configuration. It is frustrating when a single instance failure locks you out of your system. I prefer running a second “rescue” gateway on the same machine to handle these emergencies.
While most setups work fine with one gateway, you might need stronger isolation or redundancy. If you want to run a second instance without breaking the first one, you have to be careful about how they share resources.
What You’ll Need
Section titled “What You’ll Need”To run multiple gateways, you must ensure each instance has its own:
OPENCLAW_CONFIG_PATH(Unique config file)OPENCLAW_STATE_DIR(Unique sessions and caches)agents.defaults.workspace(Unique workspace root)gateway.port(Unique base port)
Quick Start
Section titled “Quick Start”The easiest way I found to do this is by using the --profile flag. This flag automatically handles the config path and state directory suffixes so you don’t have to manage environment variables manually.
1. Set up your instances
Section titled “1. Set up your instances”First, set up and install your main and rescue gateways with different ports. I recommend leaving at least 20 ports between them to avoid overlapping derived ports.
# Set up the main instanceopenclaw --profile main setupopenclaw --profile main gateway --port 18789
# Set up the rescue instance on a different portopenclaw --profile rescue setupopenclaw --profile rescue gateway --port 190012. Install the services
Section titled “2. Install the services”Once configured, you can install them as separate services.
openclaw --profile main gateway installopenclaw --profile rescue gateway installTroubleshooting
Section titled “Troubleshooting”If you run into issues, it is usually because two instances are trying to use the same resource. Here are two things I always check:
Config Races and Port Conflicts
If you don’t use profiles or unique environment variables, instances will fight over the same session files and ports. Always verify that your OPENCLAW_STATE_DIR is different for every instance. Also, ensure your base ports are far apart. OpenClaw uses derived ports for other services:
- Browser control: Base + 2
- Canvas: Base + 4
- CDP Ports: Base + 9 to Base + 108
Browser/CDP Footguns
I have seen setups fail because browser.cdpUrl was pinned to the same value on multiple instances. Do not pin this value globally. Each instance needs its own CDP range derived from its specific gateway port. If you need a remote Chrome instance, set the browser.profiles.<name>.cdpUrl specifically per profile and instance.
Ending
Section titled “Ending”If you need help configuring your specific environment, check out the AI Setup Assistant.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.