#Connect: failed - connect failed: connect ECONNREFUSED 127.0.0.1:18789

1 messages · Page 1 of 1 (latest)

weary cargo
#

As in my tui, it says the gateway is disconnected. Hence i am trying the gateway probe and got the following issue:

Gateway Status
Reachable: no
Probe budget: 3000ms

Discovery (this machine)
Found 0 gateways via Bonjour (local. + clawdbot.internal.)
Tip: if the gateway is remote, mDNS won’t cross networks; use Wide-Area Bonjour (split DNS) or SSH tunnels.

Targets
Local loopback ws://127.0.0.1:18789
Connect: failed - connect failed: connect ECONNREFUSED 127.0.0.1:18789

sick nestBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

weary cargo
#

@honest cedar Any idea how to resolve this?

honest cedarBOT
# weary cargo <@1457407575476801641> Any idea how to resolve this?

Connection refused to 127.0.0.1:18789 typically means a Discord channel is configured to use a local proxy/relay that isn't running.

Quick checks:

  1. Is a local Discord relay running? Check if you have a process on port 18789:

    lsof -i :18789
    
  2. Check the channel config - that channel (1465238840531877930) likely has a controlUrl pointing to 127.0.0.1:18789. Either:

    • Start the relay process, OR
    • Remove the controlUrl from that channel's config to use the gateway directly
  3. Restart the gateway if you recently changed configs:

    clawdbot gateway restart
    
#

Could you share:

  • Your clawdbot --version?
  • The channel config for that ID (check config.json or via clawdbot channel info 1465238840531877930)?

This is usually a misconfigured local relay. If you don't need a local relay, removing the controlUrl from that channel's config will fix it.

weary cargo
#

I have installed clawd on VPS from AWS. The version 2025.1.24-3. I have tried to restart but still the same issue is shown when run gateway probe

honest cedarBOT
# weary cargo I have installed clawd on VPS from AWS. The version 2025.1.24-3. I have tried to...

Based on my research, port 18789 is Clawdbot's main gateway port. The ECONNREFUSED error means something is trying to connect to the gateway but it's not running or not accessible.

Quick fix:

  1. Check if gateway is running:

    clawdbot gateway status
    
  2. If not running, start it:

    clawdbot gateway start
    
  3. Verify the Discord channel config - the channel 1465238840531877930 may have a controlUrl set. Check your config:

#
   clawdbot channel info 1465238840531877930
  1. If controlUrl exists and points to 127.0.0.1:18789, either:
    • Remove the controlUrl from that channel's config (let it use default), OR
    • Ensure the gateway is running and accessible

Most likely cause: The channel has a controlUrl that shouldn't be there for a VPS setup. On a remote server, you typically don't need a local relay — the channel should connect directly.

Could you run clawdbot channel info 1465238840531877930 and share the output? That will show if controlUrl is configured and what needs to be removed.

weary cargo
#

Here is what I am getting from running gateway status:

Service: systemd (enabled)
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Command: /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 18789
Service file: ~/.config/systemd/user/clawdbot-gateway.service
Service env: CLAWDBOT_GATEWAY_PORT=18789

Config (cli): ~/.clawdbot/clawdbot.json
Config (service): ~/.clawdbot/clawdbot.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: stopped (state activating, sub auto-restart, last exit 1, reason 1)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json

Service is loaded but not running (likely exited immediately).
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager

Troubles: run clawdbot status
Troubleshooting: https://docs.clawd.bot/troubleshooting

honest cedarBOT
# weary cargo Here is what I am getting from running gateway status: Service: systemd (enable...

Found the issue! 🎯

The gateway is bound to 127.0.0.1 (loopback only), but you're on a VPS. This means it only accepts local connections — external services (like Discord's webhook or channel connection) can't reach it.

Fix: Change the bind address to 0.0.0.0 (all interfaces):

# Option 1: Via environment variable
export CLAWDBOT_GATEWAY_BIND=0.0.0.0
clawdbot gateway restart

# Option 2: Via config (~/.clawdbot/clawdbot.json)
# Add or update:
{
  "gateway": {
    "bind": "0.0.0.0"
#
  }
}
clawdbot gateway restart

After restarting, the probe should show bind=0.0.0.0 and the Discord channel will be able to connect.

The key line in the status output: "Probe note: Loopback-only gateway; only local clients can connect." — that's the problem.

weary cargo
#

I tried option 1 and I am still seeing this from probe, looks like the bind address isn't changed:
Gateway Status
Reachable: no
Probe budget: 3000ms

Discovery (this machine)
Found 0 gateways via Bonjour (local. + clawdbot.internal.)
Tip: if the gateway is remote, mDNS won’t cross networks; use Wide-Area Bonjour (split DNS) or SSH tunnels.

Targets
Local loopback ws://127.0.0.1:18789
Connect: failed - connect failed: connect ECONNREFUSED 127.0.0.1:18789

honest cedarBOT
#
   [Service]
   Environment=CLAWDBOT_GATEWAY_BIND=0.0.0.0
  1. Reload and restart:

    systemctl --user daemon-reload
    clawdbot gateway restart
    
  2. Verify:

    clawdbot gateway status
    

The output should now show bind=0.0.0.0 instead of bind=loopback.

#

Alternative (config file): Add this to ~/.clawdbot/clawdbot.json:

{
  "gateway": {
    "bind": "0.0.0.0"
  }
}

Then clawdbot gateway restart.

Try the systemd edit method first — that's the cleanest fix for a VPS.

weary cargo
#

I tried the first method but I am still not seeing bind=0.0.0.0. For the alternative, I don't know where that file is, can you give me the bash command to locate the file and make the change?

#

@honest cedar Any further help with this issue, I even tried to uninstall clawdbot and the same issue is still there. Happy to try the other option though but I don't know how to locate the clawdbot.json file.

#

The main issue is till regarding the gateway:
Gateway │ local · ws://127.0.0.1:18789 (local loopback) · unreachable (connect failed: connect ECONNREFUSED 127.0.0.1:18789) │
│ Gateway service │ systemd installed · enabled · running (pid 28975, state active)

honest cedarBOT
#

Also verify the bind setting was applied:

clawdbot gateway status | grep bind

What do the logs say? That'll show why the gateway isn't responding despite the service being "running."

weary cargo
#

Can I change the port?

#

Here is the result from the bind setting:
Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json
Gateway port 18789 is not listening (service appears running).
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager

honest cedarBOT
# weary cargo Can I change the port?

Yes! Change the port:

Via environment variable:

# Set new port (e.g., 8080)
export CLAWDBOT_GATEWAY_PORT=8080
clawdbot gateway restart

Via config (~/.clawdbot/clawdbot.json):

{
  "gateway": {
    "port": 8080
  }
}
#

Then clawdbot gateway restart

After changing, verify:

clawdbot gateway status

Make sure to also update any channel configs that reference the old port if you have controlUrl settings pointing to it.

Try a different port first to see if something else is blocking 18789:

ss -tulpn | grep 18789
honest cedarBOT
# weary cargo Here is the result from the bind setting: Gateway: bind=loopback (127.0.0.1), po...

The service is "running" but the port isn't listening — the gateway process likely crashed or failed to start properly.

Check logs immediately:

journalctl --user -u clawdbot-gateway.service -n 100 --no-pager -f

Then in another terminal, restart:

clawdbot gateway restart

Watch the logs — they'll show why the gateway isn't binding to the port.

Common causes:

  • Config syntax error in ~/.clawdbot/clawdbot.json
  • Port already in use
#
  • Permission issue
  • Missing dependencies

Paste the log output after restarting — that will reveal the actual error.

weary cargo
#

I tried the change of the port, and this is what I am seeing:
Service: systemd (enabled)
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Command: /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 18789
Service file: ~/.config/systemd/user/clawdbot-gateway.service
Service env: CLAWDBOT_GATEWAY_PORT=18789

Config (cli): ~/.clawdbot/clawdbot.json
Config (service): ~/.clawdbot/clawdbot.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: stopped (state activating, sub auto-restart, last exit 1, reason 1)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json

Service is loaded but not running (likely exited immediately).
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager

Note: CLI config resolves gateway port=8080 (free).
Troubles: run clawdbot status
Troubleshooting: https://docs.clawd.bot/troubleshooting

honest cedarBOT
#
   systemctl --user daemon-reload
   clawdbot gateway restart
  1. Verify:
    clawdbot gateway status
    

You should now see bind=0.0.0.0 and port=8080. The key is the systemctl edit creates an override that takes precedence over the default service file.

weary cargo
#

Service: systemd (enabled)
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Command: /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 18789
Service file: ~/.config/systemd/user/clawdbot-gateway.service
Service env: CLAWDBOT_GATEWAY_PORT=18789

Config (cli): ~/.clawdbot/clawdbot.json
Config (service): ~/.clawdbot/clawdbot.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
This is what I am seeing after the change, do you think the change is correct?
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: running (pid 31122, state active, sub running, last exit 0, reason 0)
Warm-up: launch agents can take a few seconds. Try again shortly.
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json

Note: CLI config resolves gateway port=8080 (free).
Gateway port 18789 is not listening (service appears running).
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager

Troubles: run clawdbot status

honest cedarBOT
# weary cargo Service: systemd (enabled) File logs: /tmp/clawdbot/clawdbot-2026-01-26.log Comm...

The override isn't being applied. Let's verify the edit was saved:

Check if override exists:

cat ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf

If it doesn't exist or is empty, create it manually:

mkdir -p ~/.config/systemd/user/clawdbot-gateway.service.d
echo '[Service]
Environment=CLAWDBOT_GATEWAY_PORT=8080
Environment=CLAWDBOT_GATEWAY_BIND=0.0.0.0' > ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf

Then reload and restart:

#
systemctl --user daemon-reload
clawdbot gateway restart

Verify the override is active:

systemctl --user show clawdbot-gateway.service | grep Environment=

You should see CLAWDBOT_GATEWAY_PORT=8080 and CLAWDBOT_GATEWAY_BIND=0.0.0.0 in the output.

weary cargo
#

It looks like the port change went through, but the issue is still there. here ist he probe result:
Gateway Status
Reachable: no
Probe budget: 3000ms

Discovery (this machine)
Found 0 gateways via Bonjour (local. + clawdbot.internal.)
Tip: if the gateway is remote, mDNS won’t cross networks; use Wide-Area Bonjour (split DNS) or SSH tunnels.

Targets
Local loopback ws://127.0.0.1:8080
Connect: failed - connect failed: connect ECONNREFUSED 127.0.0.1:8080

honest cedarBOT
#

# Run manually with verbose output
/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --verbose

This will show you the actual error in real-time. The gateway is likely crashing due to a config error, missing dependency, or permission issue.

What do you see in the logs or manual run output?

weary cargo
#

This is the output from the verbose output
07:48:57 [canvas] host mounted at http://127.0.0.1:8080/__clawdbot__/canvas/ (root /home/ubuntu/clawd/canvas)
07:48:57 bonjour: starting (hostname=ip-172-31-47-237, instance="ip-172-31-47-237 (Clawdbot)", gatewayPort=8080, sshPort=22)
07:48:57 [heartbeat] started
07:48:57 [gateway] agent model: openai-codex/gpt-5.2
07:48:57 [gateway] listening on ws://127.0.0.1:8080 (PID 32218)
07:48:57 [gateway] listening on ws://[::1]:8080
07:48:57 [gateway] log file: /tmp/clawdbot/clawdbot-2026-01-26.log
07:48:57 [browser/server] Browser control listening on http://127.0.0.1:8082/
07:48:57 [ws] → event health seq=1 clients=0 presenceVersion=1 healthVersion=2
07:48:57 [telegram] [default] starting provider
07:48:57 [skills] Sanitized skill command name "skill-creator" to "/skill_creator".
07:48:57 [telegram] telegram setMyCommands failed: HttpError: Network request for 'setMyCommands' failed!
07:48:57 [clawdbot] Unhandled promise rejection: TypeError: fetch failed
at node:internal/deps/undici/undici:14902:13
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at runNextTicks (node:internal/process/task_queues:69:3)
at listOnTimeout (node:internal/timers:549:9)
at processTimers (node:internal/timers:523:7)

honest cedarBOT
# weary cargo This is the output from the verbose output 07:48:57 [canvas] host mounted at htt...

The gateway IS starting on port 8080! But it's still bound to 127.0.0.1 (loopback). The environment variable isn't being converted to the CLI argument.

Pass the bind address directly as a CLI argument:

  1. Update the systemd override:

    systemctl --user edit clawdbot-gateway.service
    
  2. Change the content to use ExecStart with the --bind flag:

    [Service]
    ExecStart=
    ExecStart=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind 0.0.0.0
    
  3. Reload and restart:

#
   systemctl --user daemon-reload
   clawdbot gateway restart
  1. Verify:
    clawdbot gateway status | grep bind
    

You should now see bind=0.0.0.0 instead of 127.0.0.1.

The fetch failed error is likely a separate issue (Telegram trying to connect and failing), but the main problem is the gateway isn't externally accessible because it's bound to loopback.

weary cargo
#

Looks like nothing is changed still:
Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json
Gateway port 18789 is not listening (service appears running).
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager

honest cedarBOT
# weary cargo Looks like nothing is changed still: Gateway: bind=loopback (127.0.0.1), port=18...

The service is still using old settings. You likely have a manually-run gateway from earlier blocking things.

1. Kill any running gateways:

pkill -f "clawdbot.*gateway"
clawdbot gateway stop

2. Verify the override file:

cat ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf

3. If the file is wrong or empty, recreate it:

mkdir -p ~/.config/systemd/user/clawdbot-gateway.service.d
#
cat > ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf << 'EOF'
[Service]
ExecStart=
ExecStart=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind 0.0.0.0
EOF

4. Reload and restart:

systemctl --user daemon-reload
clawdbot gateway restart

5. Verify:

#
clawdbot gateway status | grep -E "bind|port|Runtime"

The key is ExecStart= (with the equals sign) clears the default before setting the new one. If this doesn't work, share the output of systemctl --user show clawdbot-gateway.service | grep Exec.

weary cargo
#

Here is the result from running systemctl --user show clawdbot-gateway.service | grep Exec:
ExecMainStartTimestamp=Mon 2026-01-26 07:58:00 UTC
ExecMainStartTimestampMonotonic=9060445120
ExecMainExitTimestamp=Mon 2026-01-26 07:58:01 UTC
ExecMainExitTimestampMonotonic=9062022051
ExecMainPID=33418
ExecMainCode=1
ExecMainStatus=1
ExecStart={ path=/usr/bin/node ; argv[]=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind 0.0.0.0 ; ignore_errors=no ; start_time=[Mon 2026-01-26 07:58:00 UTC] ; stop_time=[Mon 2026-01-26 07:58:01 UTC] ; pid=33418 ; code=exited ; status=1 }
ExecStartEx={ path=/usr/bin/node ; argv[]=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind 0.0.0.0 ; flags= ; start_time=[Mon 2026-01-26 07:58:00 UTC] ; stop_time=[Mon 2026-01-26 07:58:01 UTC] ; pid=33418 ; code=exited ; status=1 }
MemoryDenyWriteExecute=no

honest cedarBOT
# weary cargo Here is the result from running systemctl --user show clawdbot-gateway.service |...

The command is now correct (--bind 0.0.0.0), but it's crashing with exit code 1.

Check what error is causing the crash:

journalctl --user -u clawdbot-gateway.service -n 30 --no-pager

Or check the full error from the manual run we did earlier. The issue might be:

  • Something else already using port 8080
  • Permission issue
  • Config error

Also check if something is using the port:

ss -tulpn | grep 8080
#

Try a different port to rule out conflicts:

# Kill any running processes
pkill -f clawdbot

# Try port 9000
/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 9000 --bind 0.0.0.0 --verbose

What error do you see in the logs? That'll tell us why it's exiting immediately.

weary cargo
honest cedarBOT
# weary cargo This is what I am seeing

Found it! The --bind option doesn't accept 0.0.0.0 — use lan instead:

Update the override:

cat > ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf << 'EOF'
[Service]
ExecStart=
ExecStart=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind lan
EOF

Reload and restart:

systemctl --user daemon-reload
clawdbot gateway restart
#

Verify:

clawdbot gateway status | grep -E "bind|port"

The valid --bind options are: loopback, lan, tailnet, auto, or custom. For a VPS, lan is what you want.

weary cargo
#

Looks like the bind is still not changed for some reason:
ubuntu@ip-172-31-47-237:/$ clawdbot gateway status | grep -E "bind|port"
Command: /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 18789
Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /home/ubuntu/.clawdbot/clawdbot.json
Service is loaded but not running (likely exited immediately).
File logs: /tmp/clawdbot/clawdbot-2026-01-26.log
Logs: journalctl --user -u clawdbot-gateway.service -n 200 --no-pager
Note: CLI config resolves gateway port=8080 (free).

honest cedarBOT
#

# Recreate the override
mkdir -p ~/.config/systemd/user/clawdbot-gateway.service.d
printf '[Service]\nExecStart=\nExecStart=/usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/clawdbot/dist/entry.js gateway --port 8080 --bind lan\n' > ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf

# Reload and restart
systemctl --user daemon-reload
clawdbot gateway restart

# Check status
clawdbot gateway status | grep -E "bind|port|Command"

The key things to verify:

  • ExecStart= (clears old value)
  • New ExecStart= with --bind lan
#

What does cat ~/.config/systemd/user/clawdbot-gateway.service.d/override.conf show?