Errors / ECONNREFUSED 18789

Fix: Connection Refused (18789)

Error: "ECONNREFUSED 127.0.0.1:18789"

What It Means

Your computer is trying to connect to port 18789 (where OpenClaw gateway listens) but nothing is there. It's like knocking on an office door that doesn't exist — no one's answering because there's no office at that address.

Common Causes

  • The gateway service isn't running (never started or was stopped)
  • Gateway crashed and hasn't restarted
  • Gateway is configured to use a different port
  • Docker container isn't running (if using Docker)
  • Something else is using port 18789

Ask Your Agent to Fix This

Copy this prompt and send it to your OpenClaw agent:

Check if the OpenClaw gateway is running. If it's not running, start it with "openclaw gateway start" and tell me the status. Also check if anything else is using port 18789.

How to Fix It

1. Start the Gateway

The simplest fix — just start the gateway:

openclaw gateway start

2. Check What's Using the Port

Something else might be using 18789:

# macOS
lsof -i :18789
# Linux
sudo lsof -i :18789
# Windows (PowerShell)
netstat -ano | findstr :18789

3. Run in Foreground to See Errors

If it keeps failing, run it in the terminal to see what's wrong:

openclaw gateway --port 18789

4. Docker Users

If running via Docker:

# Check if container is running
docker ps | grep openclaw
# Check logs
docker logs openclaw
# Run with port mapping
docker run -p 18789:18789 openclaw/openclaw:latest

Verify It's Fixed

openclaw gateway status
curl http://localhost:18789/health
openclaw doctor

How to Prevent This

  • Install the gateway as a service so it starts automatically on boot: openclaw onboard --install-daemon
  • Enable automatic restart if it crashes (included in the daemon install)
  • Use a process manager like systemd or launchd (installed automatically)
  • Set up monitoring to alert you if the gateway goes down

Related Errors

Related Guides

Still having trouble?

Ask on Discord