[GH-ISSUE #6416] [Bug]: WireGuard listens on many ports in addition to its own port #4345

Closed
opened 2026-10-31 20:39:01 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @FPu3EpOBIIIuK on GitHub (Sep 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6416

Describe the bug

When a client connects to WireGuard, for example on port 443, and then you check which ports 3x-ui is listening on, many unknown UDP ports appear. If the client disconnects, the panel still shows it as online, and even more open listening ports appear. When the kernel is restarted, the unknown ports disappear from 3x-ui's listening ports, and the client's status changes to offline.

How to reproduce the problem

  1. Create a new connection with the WireGuard type
  2. Add this connection to a client
  3. Connect to the created WireGuard
  4. In the Linux console, enter sudo ss -tulpn (Unknown open UDP ports will appear)
  5. Disconnect from WireGuard (The panel will still show the client as connected)
  6. In the Linux console, enter sudo ss -tulpn (Even more unknown open UDP ports will appear)
  7. Restart the kernel
  8. In the Linux console, enter sudo ss -tulpn (The unknown ports will disappear)

Expected behavior

When creating and connecting, only 1 port — the one on which the connection was created — should be opened

Actual behavior

Unknown ports are opened upon connection

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Xray config generation, Backend (API endpoints, login, settings)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No response

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @FPu3EpOBIIIuK on GitHub (Sep 4, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6416 ### Describe the bug When a client connects to WireGuard, for example on port 443, and then you check which ports 3x-ui is listening on, many unknown UDP ports appear. If the client disconnects, the panel still shows it as online, and even more open listening ports appear. When the kernel is restarted, the unknown ports disappear from 3x-ui's listening ports, and the client's status changes to offline. ### How to reproduce the problem 1) Create a new connection with the WireGuard type 2) Add this connection to a client 3) Connect to the created WireGuard 4) In the Linux console, enter sudo ss -tulpn (Unknown open UDP ports will appear) 5) Disconnect from WireGuard (The panel will still show the client as connected) 6) In the Linux console, enter sudo ss -tulpn (Even more unknown open UDP ports will appear) 7) Restart the kernel 8) In the Linux console, enter sudo ss -tulpn (The unknown ports will disappear) ### Expected behavior When creating and connecting, only 1 port — the one on which the connection was created — should be opened ### Actual behavior Unknown ports are opened upon connection ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Xray config generation, Backend (API endpoints, login, settings) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? _No response_ ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:39:01 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@github-actions[bot] commented on GitHub (Sep 4, 2026):

Those extra UDP ports are almost certainly not the panel or your inbound listening — for a wireguard inbound the 3x-ui process opens no UDP socket at all, and what ss -tulpn shows are Xray-core's own per-flow outbound UDP sockets. But I can't close this out yet, because one number nobody has measured decides whether they age out normally or genuinely leak. Details, then what I need.

Why the panel is not the one holding those sockets

wireguard is an Xray-core protocol, not a panel-side one. The panel converts your clients into the peers array and hands the whole thing to the Xray child process:

// internal/database/model/model.go:462
func WireguardClientsToPeers(settings string) (string, bool) {

whose doc comment states the target explicitly: "the peers array xray-core's wireguard inbound expects" (internal/database/model/model.go:452). Xray-core then owns every socket for that inbound.

Grepping the whole Go tree, the panel process creates exactly two kinds of UDP socket, both in internal/amneziawgnet/:

  • internal/amneziawgnet/relay.go:175 — net.DialUDP("udp", nil, net.UDPAddrFromAddrPort(bind))
  • internal/amneziawgnet/portfwd_udp.go:49 — (&net.ListenConfig{}).ListenPacket(context.Background(), "udp", ...)

and that whole runtime only ever starts for the AmneziaWG protocol, not WireGuard:

// internal/amneziawg/instance.go:28
if ib == nil || ib.Protocol != model.AmneziaWG {
    return Instance{}, false
}

Those are two different dropdown entries with completely different implementations — the docs table spells it out: docs/content/docs/en/config/inbounds.mdx:60-61, WireGuard = "Modern tunnel" (Xray-core), AmneziaWG = "Obfuscated WireGuard fork, embedded in the panel process".

Why they look like "listening" ports, and why they go away on a core restart

Two things are worth separating:

  1. -l in ss -tulpn does not mean "listening" for UDP — UDP has no listen state, so -l matches every socket in UNCONN, which includes every unconnected outbound socket a proxy opens to send traffic on your behalf. Nothing is reachable from outside on those ports in the way a service port is. This is not WireGuard-specific: any inbound carrying UDP (DNS, QUIC/HTTP3, games, torrents) produces the same picture.
  2. How long they stay is Xray's idle policy. The template the panel ships sets no connIdle (internal/web/service/config.json:48-61 — level 0 carries only statsUserDownlink/statsUserUplink), so Xray's own default applies. The panel documents that default in its own UI string:

internal/web/translation/en-US.json:1659 — "Closes a connection after it stays idle for this many seconds. Lowering it frees memory and file descriptors faster on busy servers (Xray default: 300)."

So an idle flow's socket is expected to survive up to ~5 minutes after the peer goes quiet. Your step 7 restarted the core well inside that window, which drops every socket at once — the same thing waiting would have done. You can lower it in the panel: Xray Configs → Connection Limits → Idle Timeout (frontend/src/pages/xray/basics/BasicsTab.tsx:371, writes policy.levels.0.connIdle; the panel preserves it, it only force-enables statsUserOnline — internal/web/service/xray.go:1001).

The "still shows as connected" half is the same fact

WireGuard is connectionless: the server never learns a peer left. The panel does not invent an online timer — it takes Xray's answer and ages it out after 20 seconds:

// internal/web/service/inbound_node.go:200
const onlineGracePeriodMs int64 = 20000

fed by GetOnlineUsers over Xray's stats API (internal/xray/api.go:808) unioned with per-poll byte deltas (internal/web/job/xray_traffic_job.go:122-137). So the client stays "online" for exactly as long as Xray still holds sessions or moves bytes for that peer — the same lingering sessions that hold the sockets. One cause, two symptoms.

What I need to settle it

The one thing that separates "normal flow sockets aging out" from "a real socket leak" is whether the count comes back down on its own. Please, with nothing restarted:

  1. Paste the full sudo ss -ulpn line for two or three of the unknown ports, as text, including the users:(("...",pid=...)) column — that names the owning process (xray vs x-ui) and settles the attribution above outright.
  2. Run this immediately after disconnecting the client, then again 6+ minutes later without restarting anything, and post both numbers:
    sudo ss -uanp | grep -c xray
    
  3. Confirm which protocol the inbound actually uses — the panel offers both WireGuard and AmneziaWG, and per the code above only one of them can involve the panel process — plus your current Idle Timeout value on the Xray Configs page (empty = Xray's 300 s).

If the count falls back to baseline in step 2, this is ordinary proxy behaviour and the answer is the connIdle knob. If it keeps climbing across connect/disconnect cycles and never drops, that is a real socket leak worth chasing — post the numbers here first either way.

I could not verify Xray-core's socket handling directly: this checkout pins it as a module (go.mod:28, github.com/xtls/xray-core v1.260327.1-0.20260728075948-5ca6f4b7d4dc) and its source is not readable here, so the "one unconnected socket per proxied UDP flow" part is inference from the panel side, not something I read in that code.

Verdict:        Insufficient information
Severity:       N/A
Confidence:     Medium
Root cause:     None found in the panel. For a `wireguard` inbound the panel only emits peers into the
                Xray config (internal/database/model/model.go:462) and Xray-core owns every socket; the
                panel process' own UDP sockets exist solely in internal/amneziawgnet (relay.go:175,
                portfwd_udp.go:49), gated to model.AmneziaWG at internal/amneziawg/instance.go:28.
                Socket lifetime is governed by Xray's connIdle, which the shipped template leaves unset
                (internal/web/service/config.json:48-61), i.e. Xray's 300 s default.
Already fixed:  Not applicable — no panel-side defect identified; reporter is on the current release
                (v3.7.0, 2026-08-24).
Duplicate of:   None. Related: #5893 — same "panel still reports a peer Xray has not released" shape,
                different subsystem (IP-limit scanning), not a shared root cause.
Evidence:       internal/database/model/model.go:452,462 ("the peers array xray-core's wireguard inbound
                expects"); internal/amneziawg/instance.go:28 `if ib == nil || ib.Protocol != model.AmneziaWG`;
                internal/amneziawgnet/relay.go:175, portfwd_udp.go:49 (the only UDP sockets in the Go tree);
                internal/web/service/config.json:48-61 (no connIdle in the shipped policy);
                internal/web/translation/en-US.json:1659 ("Xray default: 300");
                frontend/src/pages/xray/basics/BasicsTab.tsx:371 (connIdle is user-editable);
                internal/web/service/xray.go:1001 ensureStatsPolicy (only statsUserOnline is forced);
                internal/web/service/inbound_node.go:200 onlineGracePeriodMs = 20000;
                internal/xray/api.go:808 GetOnlineUsers; internal/web/job/xray_traffic_job.go:122-137;
                docs/content/docs/en/config/inbounds.mdx:60-61.
Not determined: Whether the UDP socket count returns to baseline on its own. Settled by ask #2 — the same
                `ss -uanp | grep -c xray` count taken twice, 6+ minutes apart, with nothing restarted.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5547496618 --> @github-actions[bot] commented on GitHub (Sep 4, 2026): Those extra UDP ports are almost certainly **not** the panel or your inbound listening — for a `wireguard` inbound the 3x-ui process opens no UDP socket at all, and what `ss -tulpn` shows are Xray-core's own per-flow outbound UDP sockets. But I can't close this out yet, because one number nobody has measured decides whether they age out normally or genuinely leak. Details, then what I need. ### Why the panel is not the one holding those sockets `wireguard` is an Xray-core protocol, not a panel-side one. The panel converts your clients into the `peers` array and hands the whole thing to the Xray child process: ```go // internal/database/model/model.go:462 func WireguardClientsToPeers(settings string) (string, bool) { ``` whose doc comment states the target explicitly: *"the peers array xray-core's wireguard inbound expects"* (`internal/database/model/model.go:452`). Xray-core then owns every socket for that inbound. Grepping the whole Go tree, the panel process creates exactly two kinds of UDP socket, both in `internal/amneziawgnet/`: - `internal/amneziawgnet/relay.go:175` — `net.DialUDP("udp", nil, net.UDPAddrFromAddrPort(bind))` - `internal/amneziawgnet/portfwd_udp.go:49` — `(&net.ListenConfig{}).ListenPacket(context.Background(), "udp", ...)` and that whole runtime only ever starts for the **AmneziaWG** protocol, not WireGuard: ```go // internal/amneziawg/instance.go:28 if ib == nil || ib.Protocol != model.AmneziaWG { return Instance{}, false } ``` Those are two different dropdown entries with completely different implementations — the docs table spells it out: `docs/content/docs/en/config/inbounds.mdx:60-61`, WireGuard = *"Modern tunnel"* (Xray-core), AmneziaWG = *"Obfuscated WireGuard fork, **embedded in the panel process**"*. ### Why they look like "listening" ports, and why they go away on a core restart Two things are worth separating: 1. `-l` in `ss -tulpn` does not mean "listening" for UDP — UDP has no listen state, so `-l` matches every socket in `UNCONN`, which includes every *unconnected outbound* socket a proxy opens to send traffic on your behalf. Nothing is reachable from outside on those ports in the way a service port is. This is not WireGuard-specific: any inbound carrying UDP (DNS, QUIC/HTTP3, games, torrents) produces the same picture. 2. How long they stay is Xray's idle policy. The template the panel ships sets no `connIdle` (`internal/web/service/config.json:48-61` — level `0` carries only `statsUserDownlink`/`statsUserUplink`), so Xray's own default applies. The panel documents that default in its own UI string: > `internal/web/translation/en-US.json:1659` — *"Closes a connection after it stays idle for this many seconds. Lowering it frees memory and file descriptors faster on busy servers (Xray default: 300)."* So an idle flow's socket is expected to survive up to **~5 minutes** after the peer goes quiet. Your step 7 restarted the core well inside that window, which drops every socket at once — the same thing waiting would have done. You can lower it in the panel: **Xray Configs → Connection Limits → Idle Timeout** (`frontend/src/pages/xray/basics/BasicsTab.tsx:371`, writes `policy.levels.0.connIdle`; the panel preserves it, it only force-enables `statsUserOnline` — `internal/web/service/xray.go:1001`). ### The "still shows as connected" half is the same fact WireGuard is connectionless: the server never learns a peer left. The panel does not invent an online timer — it takes Xray's answer and ages it out after 20 seconds: ```go // internal/web/service/inbound_node.go:200 const onlineGracePeriodMs int64 = 20000 ``` fed by `GetOnlineUsers` over Xray's stats API (`internal/xray/api.go:808`) unioned with per-poll byte deltas (`internal/web/job/xray_traffic_job.go:122-137`). So the client stays "online" for exactly as long as Xray still holds sessions or moves bytes for that peer — the same lingering sessions that hold the sockets. One cause, two symptoms. ### What I need to settle it The one thing that separates "normal flow sockets aging out" from "a real socket leak" is whether the count comes back down on its own. Please, with **nothing restarted**: 1. Paste the full `sudo ss -ulpn` line for two or three of the unknown ports, as text, including the `users:(("...",pid=...))` column — that names the owning process (`xray` vs `x-ui`) and settles the attribution above outright. 2. Run this immediately after disconnecting the client, then again **6+ minutes later** without restarting anything, and post both numbers: ``` sudo ss -uanp | grep -c xray ``` 3. Confirm which protocol the inbound actually uses — the panel offers both **WireGuard** and **AmneziaWG**, and per the code above only one of them can involve the panel process — plus your current **Idle Timeout** value on the Xray Configs page (empty = Xray's 300 s). If the count falls back to baseline in step 2, this is ordinary proxy behaviour and the answer is the `connIdle` knob. If it keeps climbing across connect/disconnect cycles and never drops, that is a real socket leak worth chasing — post the numbers here first either way. I could not verify Xray-core's socket handling directly: this checkout pins it as a module (`go.mod:28`, `github.com/xtls/xray-core v1.260327.1-0.20260728075948-5ca6f4b7d4dc`) and its source is not readable here, so the "one unconnected socket per proxied UDP flow" part is inference from the panel side, not something I read in that code. ```text Verdict: Insufficient information Severity: N/A Confidence: Medium Root cause: None found in the panel. For a `wireguard` inbound the panel only emits peers into the Xray config (internal/database/model/model.go:462) and Xray-core owns every socket; the panel process' own UDP sockets exist solely in internal/amneziawgnet (relay.go:175, portfwd_udp.go:49), gated to model.AmneziaWG at internal/amneziawg/instance.go:28. Socket lifetime is governed by Xray's connIdle, which the shipped template leaves unset (internal/web/service/config.json:48-61), i.e. Xray's 300 s default. Already fixed: Not applicable — no panel-side defect identified; reporter is on the current release (v3.7.0, 2026-08-24). Duplicate of: None. Related: #5893 — same "panel still reports a peer Xray has not released" shape, different subsystem (IP-limit scanning), not a shared root cause. Evidence: internal/database/model/model.go:452,462 ("the peers array xray-core's wireguard inbound expects"); internal/amneziawg/instance.go:28 `if ib == nil || ib.Protocol != model.AmneziaWG`; internal/amneziawgnet/relay.go:175, portfwd_udp.go:49 (the only UDP sockets in the Go tree); internal/web/service/config.json:48-61 (no connIdle in the shipped policy); internal/web/translation/en-US.json:1659 ("Xray default: 300"); frontend/src/pages/xray/basics/BasicsTab.tsx:371 (connIdle is user-editable); internal/web/service/xray.go:1001 ensureStatsPolicy (only statsUserOnline is forced); internal/web/service/inbound_node.go:200 onlineGracePeriodMs = 20000; internal/xray/api.go:808 GetOnlineUsers; internal/web/job/xray_traffic_job.go:122-137; docs/content/docs/en/config/inbounds.mdx:60-61. Not determined: Whether the UDP socket count returns to baseline on its own. Settled by ask #2 — the same `ss -uanp | grep -c xray` count taken twice, 6+ minutes apart, with nothing restarted. ``` *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@FPu3EpOBIIIuK commented on GitHub (Sep 4, 2026):

Protocol: WireGuard

Output of the command sudo ss -ulpn

UNCONN  0        0           *:44...                *:*      users:(("xray-linux-amd6",pid=XXX,fd=15))
UNCONN  0        0           *:54...                *:*      users:(("xray-linux-amd6",pid=XXX,fd=55))
UNCONN  0        0           *:39...                *:*      users:(("xray-linux-amd6",pid=XXX,fd=39))

Output of the command sudo ss -uanp | grep -c xray
52

utput of the command sudo ss -uanp | grep -c xray after 6+ minutes
15

<!-- gh-comment-id:5547679264 --> @FPu3EpOBIIIuK commented on GitHub (Sep 4, 2026): Protocol: WireGuard Output of the command sudo ss -ulpn ``` UNCONN 0 0 *:44... *:* users:(("xray-linux-amd6",pid=XXX,fd=15)) UNCONN 0 0 *:54... *:* users:(("xray-linux-amd6",pid=XXX,fd=55)) UNCONN 0 0 *:39... *:* users:(("xray-linux-amd6",pid=XXX,fd=39)) ``` Output of the command sudo ss -uanp | grep -c xray 52 utput of the command sudo ss -uanp | grep -c xray after 6+ minutes 15
Author
Owner

@github-actions[bot] commented on GitHub (Sep 4, 2026):

Thanks — your two numbers settle it, and the answer is that this is normal Xray-core behaviour, not a panel bug and not a socket leak. Both open questions from my last comment are now answered by your own output.

1. The sockets belong to Xray-core, not to 3x-ui

Your ss output names the owner as xray-linux-amd6. ss truncates the process name to 15 characters, so that is xray-linux-amd64 — which is exactly the string the panel builds when it launches its managed child process:

// internal/xray/process.go:26-31
func GetBinaryName() string {
	arch := runtime.GOARCH
	if arch == "arm" {
		arch = "arm32"
	}
	return fmt.Sprintf("xray-%s-%s", runtime.GOOS, arch)
}

On linux/amd64 that is xray-linux-amd64. None of the sockets are held by x-ui, which confirms the attribution I described last time: for a wireguard inbound the panel only emits the peers array into the Xray config (internal/database/model/model.go:462) and Xray-core owns every socket from there. The panel's own UDP sockets live only in internal/amneziawgnet/, gated to the AmneziaWG protocol at internal/amneziawg/instance.go:28:

if ib == nil || ib.Protocol != model.AmneziaWG {
	return Instance{}, false
}

You confirmed the inbound is WireGuard, so that runtime never starts.

2. The count comes back down on its own — that is the whole test

immediately after disconnect:   52
6+ minutes later, no restart:   15

That is the exact measurement that separates "ordinary flow sockets aging out" from "a real leak", and it decayed on its own with nothing restarted. It matches Xray's connIdle default of 300 seconds, which applies because the config template the panel ships sets no connIdle at all — level 0 carries only statsUserDownlink/statsUserUplink (internal/web/service/config.json:48-61). The panel states that default in its own UI string:

internal/web/translation/en-US.json:1659 — "Closes a connection after it stays idle for this many seconds. Lowering it frees memory and file descriptors faster on busy servers (Xray default: 300)."

Your step 7 in the original report ("restart the kernel") just dropped every socket at once, inside that 5-minute window — the same thing waiting did.

Two things worth keeping in mind about the picture itself:

  • -l in ss -tulpn does not mean "listening" for UDP. UDP has no listen state, so -l matches every socket in UNCONN, including every unconnected outbound socket a proxy opens to send traffic on your behalf. Nothing is externally reachable on those ports the way your inbound's port is. Any inbound carrying UDP (DNS, QUIC/HTTP3, games, torrents) produces the same picture — it is not WireGuard-specific.
  • If you want them released sooner, lower Xray Configs → Connection Limits → Idle Timeout in the panel (frontend/src/pages/xray/basics/BasicsTab.tsx:361-374, writes policy.levels.0.connIdle; the panel preserves your value and only force-enables statsUserOnline — ensureStatsPolicy, internal/web/service/xray.go:1001). The field is empty by default, which means Xray's 300.

3. "Still shows as connected" is the same fact, not a second bug

WireGuard is connectionless — the server never learns a peer left. The panel does not invent an online timer; it takes Xray's answer and ages it out after 20 seconds:

// internal/web/service/inbound_node.go:200
const onlineGracePeriodMs int64 = 20000

fed by GetOnlineUsers over Xray's stats API (internal/xray/api.go:808) unioned with per-poll byte deltas (internal/web/job/xray_traffic_job.go:122-137). So the client stays "online" exactly as long as Xray still holds sessions for that peer — the same lingering sessions that hold the sockets. One cause, two symptoms, and both clear on the same connIdle timer.

Closing this as expected behaviour. One honest gap: you did not measure the count before connecting, so I cannot say 15 is precisely your baseline rather than a slightly elevated one. If you ever see it climb monotonically across many connect/disconnect cycles and never return near a measured pre-connection baseline, that would be a different finding — post the baseline number and the series and it can be reopened.

Verdict:        Not a bug (expected behaviour)
Severity:       N/A
Confidence:     High
Root cause:     None in the panel. Reporter's own `ss` output names the owner `xray-linux-amd6`, i.e.
                `xray-linux-amd64` per internal/xray/process.go:26-31 — the managed Xray child, not
                `x-ui`. For a `wireguard` inbound the panel only emits peers into the Xray config
                (internal/database/model/model.go:462); its own UDP sockets exist solely in
                internal/amneziawgnet (relay.go:175, portfwd_udp.go:49), gated to model.AmneziaWG at
                internal/amneziawg/instance.go:28, and the reporter confirmed the protocol is WireGuard.
                Socket lifetime is Xray's connIdle, left unset by the shipped template
                (internal/web/service/config.json:48-61) = Xray's 300 s default. Reporter measured the
                count decaying 52 -> 15 over 6+ minutes with nothing restarted, which is that timer.
Already fixed:  Not applicable — no defect. Reporter is on the current release (v3.7.0).
Duplicate of:   None
Evidence:       internal/xray/process.go:26-31 `fmt.Sprintf("xray-%s-%s", runtime.GOOS, arch)` ->
                `xray-linux-amd64`, truncated by ss to the reporter's `xray-linux-amd6`;
                internal/amneziawg/instance.go:28 `if ib == nil || ib.Protocol != model.AmneziaWG`;
                internal/amneziawgnet/relay.go:175, portfwd_udp.go:49 (only UDP sockets in the Go tree);
                internal/database/model/model.go:452,462 WireguardClientsToPeers;
                internal/web/service/config.json:48-61 (policy level 0 has no connIdle);
                internal/web/translation/en-US.json:1659 ("Xray default: 300");
                frontend/src/pages/xray/basics/BasicsTab.tsx:361-374 (connIdle is user-editable,
                placeholder "300"); internal/web/service/xray.go:1001 ensureStatsPolicy (forces only
                statsUserOnline, preserves the rest); internal/web/service/inbound_node.go:200
                onlineGracePeriodMs = 20000; internal/xray/api.go:808 GetOnlineUsers;
                internal/web/job/xray_traffic_job.go:122-137.
Not determined: The pre-connection baseline socket count, so "15" cannot be pinned as exactly baseline
                versus slightly elevated. Settled by one `sudo ss -uanp | grep -c xray` taken before any
                client connects, compared against the post-idle value.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5547694498 --> @github-actions[bot] commented on GitHub (Sep 4, 2026): Thanks — your two numbers settle it, and the answer is that this is normal Xray-core behaviour, not a panel bug and not a socket leak. Both open questions from my last comment are now answered by your own output. ### 1. The sockets belong to Xray-core, not to 3x-ui Your `ss` output names the owner as `xray-linux-amd6`. `ss` truncates the process name to 15 characters, so that is `xray-linux-amd64` — which is exactly the string the panel builds when it launches its managed child process: ```go // internal/xray/process.go:26-31 func GetBinaryName() string { arch := runtime.GOARCH if arch == "arm" { arch = "arm32" } return fmt.Sprintf("xray-%s-%s", runtime.GOOS, arch) } ``` On `linux/amd64` that is `xray-linux-amd64`. None of the sockets are held by `x-ui`, which confirms the attribution I described last time: for a `wireguard` inbound the panel only emits the `peers` array into the Xray config (`internal/database/model/model.go:462`) and Xray-core owns every socket from there. The panel's own UDP sockets live only in `internal/amneziawgnet/`, gated to the **AmneziaWG** protocol at `internal/amneziawg/instance.go:28`: ```go if ib == nil || ib.Protocol != model.AmneziaWG { return Instance{}, false } ``` You confirmed the inbound is `WireGuard`, so that runtime never starts. ### 2. The count comes back down on its own — that is the whole test ``` immediately after disconnect: 52 6+ minutes later, no restart: 15 ``` That is the exact measurement that separates "ordinary flow sockets aging out" from "a real leak", and it decayed on its own with nothing restarted. It matches Xray's `connIdle` default of **300 seconds**, which applies because the config template the panel ships sets no `connIdle` at all — level `0` carries only `statsUserDownlink`/`statsUserUplink` (`internal/web/service/config.json:48-61`). The panel states that default in its own UI string: > `internal/web/translation/en-US.json:1659` — *"Closes a connection after it stays idle for this many seconds. Lowering it frees memory and file descriptors faster on busy servers (Xray default: 300)."* Your step 7 in the original report ("restart the kernel") just dropped every socket at once, inside that 5-minute window — the same thing waiting did. Two things worth keeping in mind about the picture itself: - `-l` in `ss -tulpn` does **not** mean "listening" for UDP. UDP has no listen state, so `-l` matches every socket in `UNCONN`, including every *unconnected outbound* socket a proxy opens to send traffic on your behalf. Nothing is externally reachable on those ports the way your inbound's port is. Any inbound carrying UDP (DNS, QUIC/HTTP3, games, torrents) produces the same picture — it is not WireGuard-specific. - If you want them released sooner, lower **Xray Configs → Connection Limits → Idle Timeout** in the panel (`frontend/src/pages/xray/basics/BasicsTab.tsx:361-374`, writes `policy.levels.0.connIdle`; the panel preserves your value and only force-enables `statsUserOnline` — `ensureStatsPolicy`, `internal/web/service/xray.go:1001`). The field is empty by default, which means Xray's 300. ### 3. "Still shows as connected" is the same fact, not a second bug WireGuard is connectionless — the server never learns a peer left. The panel does not invent an online timer; it takes Xray's answer and ages it out after 20 seconds: ```go // internal/web/service/inbound_node.go:200 const onlineGracePeriodMs int64 = 20000 ``` fed by `GetOnlineUsers` over Xray's stats API (`internal/xray/api.go:808`) unioned with per-poll byte deltas (`internal/web/job/xray_traffic_job.go:122-137`). So the client stays "online" exactly as long as Xray still holds sessions for that peer — the same lingering sessions that hold the sockets. One cause, two symptoms, and both clear on the same `connIdle` timer. Closing this as expected behaviour. One honest gap: you did not measure the count *before* connecting, so I cannot say 15 is precisely your baseline rather than a slightly elevated one. If you ever see it climb monotonically across many connect/disconnect cycles and never return near a measured pre-connection baseline, that would be a different finding — post the baseline number and the series and it can be reopened. ```text Verdict: Not a bug (expected behaviour) Severity: N/A Confidence: High Root cause: None in the panel. Reporter's own `ss` output names the owner `xray-linux-amd6`, i.e. `xray-linux-amd64` per internal/xray/process.go:26-31 — the managed Xray child, not `x-ui`. For a `wireguard` inbound the panel only emits peers into the Xray config (internal/database/model/model.go:462); its own UDP sockets exist solely in internal/amneziawgnet (relay.go:175, portfwd_udp.go:49), gated to model.AmneziaWG at internal/amneziawg/instance.go:28, and the reporter confirmed the protocol is WireGuard. Socket lifetime is Xray's connIdle, left unset by the shipped template (internal/web/service/config.json:48-61) = Xray's 300 s default. Reporter measured the count decaying 52 -> 15 over 6+ minutes with nothing restarted, which is that timer. Already fixed: Not applicable — no defect. Reporter is on the current release (v3.7.0). Duplicate of: None Evidence: internal/xray/process.go:26-31 `fmt.Sprintf("xray-%s-%s", runtime.GOOS, arch)` -> `xray-linux-amd64`, truncated by ss to the reporter's `xray-linux-amd6`; internal/amneziawg/instance.go:28 `if ib == nil || ib.Protocol != model.AmneziaWG`; internal/amneziawgnet/relay.go:175, portfwd_udp.go:49 (only UDP sockets in the Go tree); internal/database/model/model.go:452,462 WireguardClientsToPeers; internal/web/service/config.json:48-61 (policy level 0 has no connIdle); internal/web/translation/en-US.json:1659 ("Xray default: 300"); frontend/src/pages/xray/basics/BasicsTab.tsx:361-374 (connIdle is user-editable, placeholder "300"); internal/web/service/xray.go:1001 ensureStatsPolicy (forces only statsUserOnline, preserves the rest); internal/web/service/inbound_node.go:200 onlineGracePeriodMs = 20000; internal/xray/api.go:808 GetOnlineUsers; internal/web/job/xray_traffic_job.go:122-137. Not determined: The pre-connection baseline socket count, so "15" cannot be pinned as exactly baseline versus slightly elevated. Settled by one `sudo ss -uanp | grep -c xray` taken before any client connects, compared against the post-idle value. ``` *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4345
No description provided.