Skip to content

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.

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)

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.

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.

Terminal window
# Set up the main instance
openclaw --profile main setup
openclaw --profile main gateway --port 18789
# Set up the rescue instance on a different port
openclaw --profile rescue setup
openclaw --profile rescue gateway --port 19001

Once configured, you can install them as separate services.

Terminal window
openclaw --profile main gateway install
openclaw --profile rescue gateway install

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.

If you need help configuring your specific environment, check out 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.