{"id":"XE-16976","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"691","source_url":"https://github.com/xeprotocol/xe/issues/691","reporter_id":2920,"title":"[Low] xe node prints \"API/UI listening\" even when the bind fails; node keeps running headless","area":"node-api","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T08:11:51.887286+00:00","updated_at":"2026-11-22T23:26:11.727612+00:00","source_created_at":"2026-11-17T08:11:41+00:00","told_at":"2026-11-22T23:26:11.742477+00:00","status_changed_at":"2026-11-22T23:26:11.733211+00:00","url":"https://bounty.xe.network/XE-16976","body":"## Summary\n\n`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.\n\n## Root Cause\n\n- The \"listening\" log lines are printed *inside* the server goroutines before `ListenAndServe` is called (`cmd/xe/main.go:1466-1468` API, `:1541` UI).\n- The stdout lines (`:1550` \"API listening on port %d\", `:1553` \"UI listening on port %d\") print unconditionally after launching the goroutines.\n- A bind failure only surfaces as a log ERROR inside the goroutine; nothing fails the startup, so the node keeps running with no API.\n\n## Verification\n\nExecuted PoC (squatted 127.0.0.1:18080 with a dummy server, then ran `xe node --api-port 18080 --ui --ui-port 18081`):\n\n```\nINFO \"API listening on 127.0.0.1:18080\"\nERROR \"API server error: listen tcp 127.0.0.1:18080: bind: address already in use\"\nAPI listening on port 18080\nUI listening on port 18081\n```\n\nThe 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)`).\n\n## Note on related reports\n\nSearched \"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.\n\n## Suggested fix\n\nBind 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.\n","patch_refs":[],"thread":[{"id":18797,"source":"desk","source_ref":"reply:16474","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16976 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:11.727612+00:00"}]}