<!-- XE-16976 · [Low] xe node prints "API/UI listening" even when the bind fails; node keeps running headless · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16976>. The page is the record; this is the same page for reading.*

XE-16976 · Bounty

# \[Low\] xe node prints "API/UI listening" even when the bind fails; node keeps running headless

Closed · duplicate
—
[xe#691](https://github.com/xeprotocol/xe/issues/691)
filed 2026-11-17 08:11 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770173](https://bounty.xe.network/log/770173) 2026-11-22 23:26 UTC reply.mirror\_failed
- [769824](https://bounty.xe.network/log/769824) 2026-11-22 23:26 UTC proposal.adopted
- [769823](https://bounty.xe.network/log/769823) 2026-11-22 23:26 UTC reply.sent
- [769822](https://bounty.xe.network/log/769822) 2026-11-22 23:26 UTC ticket.status new → closed
- [768759](https://bounty.xe.network/log/768759) 2026-11-22 23:25 UTC proposal.adopted
- [768758](https://bounty.xe.network/log/768758) 2026-11-22 23:25 UTC ticket.facts area
- [768757](https://bounty.xe.network/log/768757) 2026-11-22 23:25 UTC proposal.adopted
- [768756](https://bounty.xe.network/log/768756) 2026-11-22 23:25 UTC ticket.facts
- [768755](https://bounty.xe.network/log/768755) 2026-11-22 23:25 UTC proposal.adopted
- [768754](https://bounty.xe.network/log/768754) 2026-11-22 23:25 UTC ticket.facts
- [766685](https://bounty.xe.network/log/766685) 2026-11-22 23:18 UTC note.added
- [766684](https://bounty.xe.network/log/766684) 2026-11-22 23:18 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-16976) · [JSON](https://bounty.xe.network/v1/tickets/XE-16976) · [markdown](https://bounty.xe.network/XE-16976.md)

### Report

## Summary

`xe node` prints "API listening on port N" / "UI listening on port N" even when the bind fails, and the node keeps running headless with no API. The "listening" lines are printed before `ListenAndServe` attempts the bind, so a bind failure only surfaces as a log ERROR inside the goroutine while stdout claims success.

## Root Cause

- The "listening" log lines are printed *inside* the server goroutines before `ListenAndServe` is called (`cmd/xe/main.go:1466-1468` API, `:1541` UI).
- The stdout lines (`:1550` "API listening on port %d", `:1553` "UI listening on port %d") print unconditionally after launching the goroutines.
- A bind failure only surfaces as a log ERROR inside the goroutine; nothing fails the startup, so the node keeps running with no API.

## Verification

Executed PoC (squatted 127.0.0.1:18080 with a dummy server, then ran `xe node --api-port 18080 --ui --ui-port 18081`):

```
INFO "API listening on 127.0.0.1:18080"
ERROR "API server error: listen tcp 127.0.0.1:18080: bind: address already in use"
API listening on port 18080
UI listening on port 18081
```

The process kept running until killed. Bonus consequence: the UI claims to proxy `/api/*` to the dead API port — whatever process holds that port receives the wallet UI's API traffic (`UI listening on 127.0.0.1:18081 (proxying /api/* to http://127.0.0.1:18080, wallet enabled)`).

## Note on related reports

Searched "API listening port bind fail" and "address already in use bind" — #558 (failed `node.New()` leaks listener/goroutines) and #60 (SIGTERM shutdown hang) are adjacent but different mechanisms.

## Suggested fix

Bind the listeners (or attempt `ListenAndServe` and check the error) before printing the "listening" lines, and fail startup — or at least exit non-zero — when a configured server cannot bind.

### Thread

**Joseph Denne**team2026-11-22 23:26 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-16976 and says what differs; it is read like any other.
