How to Change OpenClaw Default Port
The OpenClaw gateway defaults to port 18789. Here's how to change it, fix port conflicts, set up reverse proxies, and run multiple instances.
OpenClaw Default Port
Why Change the Port?
- Port 18789 is already used by another service
- Running multiple OpenClaw instances
- Hosting provider blocks the default port
- Using a reverse proxy (Nginx, Caddy) on a VPS
- Running a single instance locally
- No other services use port 18789
- Using managed hosting (handled for you)
Three Ways to Change the Port
openclaw gateway --port 9000Overrides the port for this session only. Does not change the config file.
Edit ~/.openclaw/openclaw.json and add the port setting:
{
"gateway": {
"port": 9000
}
}Then restart the gateway:
openclaw gateway restartopenclaw config set gateway.port 9000
openclaw gateway restartUpdates the config file and restarts in two commands.
Fix "Port Already in Use" Error
If the gateway will not start because port 18789 is taken, find what is using it:
# Linux / macOS
lsof -i :18789
# Windows
netstat -ano | findstr 18789Then either:
- Kill the conflicting process -
kill <PID> - Change OpenClaw's port - use one of the three methods above
- Check for zombie gateway processes -
pkill -f "openclaw gateway"then restart
For more gateway troubleshooting, see OpenClaw Gateway Won't Start.
Setting Up a Reverse Proxy
For production, put Nginx or Caddy in front of OpenClaw. The gateway listens on localhost and the proxy handles SSL and external traffic.
# Nginx reverse proxy config
server {
listen 443 ssl;
server_name openclaw.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/openclaw.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/openclaw.yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:18789;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Important: The Upgrade and Connection headers are required for WebSocket support. Without them, real-time features and channel connections will break.
Network Binding Options
| Bind Mode | Listens On | Use Case |
|---|---|---|
| loopback (safest) | 127.0.0.1 only | Local use, behind reverse proxy |
| auto (default) | Auto-detected interface | Most deployments |
| lan | LAN interface | Access from other devices on network |
| custom | Specific IP you choose | Multi-NIC servers |
| tailnet | Tailscale interface | Secure remote access via Tailscale |
Set bind mode in your config:
{
"gateway": {
"port": 9000,
"bind": "loopback"
}
}Running Multiple Instances
Run two OpenClaw instances on the same server with different ports:
# Instance 1 (default)
openclaw gateway --port 18789
# Instance 2 (different config)
OPENCLAW_CONFIG_PATH=~/.openclaw/openclaw-2.json openclaw gateway --port 18790Each instance needs its own config file and workspace directory to avoid conflicts. For cost optimization with multiple instances, see how to reduce API costs.
Firewall Rules
Only open the port if external access is needed:
# UFW (Ubuntu/Debian)
sudo ufw allow 18789/tcp
# firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-port=18789/tcp
sudo firewall-cmd --reload
# iptables
sudo iptables -A INPUT -p tcp --dport 18789 -j ACCEPTBest practice: Keep OpenClaw on loopback (127.0.0.1) and use a reverse proxy for external access. Do not expose the gateway port directly to the internet. See the uptime guide for production hardening.
Skip Port Configuration
On Ampere.sh managed hosting, ports, SSL, reverse proxy, and firewall are all handled for you. No terminal, no config files, no networking headaches. See managed vs self-hosted for the full comparison.
Quick Reference
| Action | Command |
|---|---|
| Check current port | openclaw gateway status |
| Change port (temp) | openclaw gateway --port 9000 |
| Change port (permanent) | openclaw config set gateway.port 9000 |
| Restart gateway | openclaw gateway restart |
| Check what uses a port | lsof -i :18789 |
| Kill gateway processes | pkill -f "openclaw gateway" |
For the full setup, see the beginner guide. For Docker deployments, see OpenClaw on Docker. If your gateway will not start at all, see the gateway troubleshooting guide.
Frequently Asked Questions
What is the default OpenClaw port?
How do I change the OpenClaw port?
Why would I change the OpenClaw port?
How do I fix 'port already in use' errors?
Do I need to open the port in my firewall?
Can I run multiple OpenClaw instances on one server?
Should I use a reverse proxy with OpenClaw?
Also Read
Skip the server config
Managed hosting handles ports, SSL, firewalls, and reverse proxies. No terminal needed. 7-day free trial.
Start Free Trial

