[GH-ISSUE #5856] [Bug]: Xray stops listening local interfaces #4067

Closed
opened 2026-10-31 20:36:54 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @aplafoe on GitHub (Jul 8, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5856

Describe the bug

Time by time Xray stops listen inbounds. ss -tlnp doesn't display them. xray logs, x-ui journalctl and dmesg also doesn't provide any helpful info. The web-panel displays xray-core as a normal running state. Restart x-ui service or just xray-core thru web-panel fix it, bit it happens again later

How to reproduce the problem

  1. Create 2 or more Inbounds on slave-node (e.g. 127.0.0.1:1443 vless xhttp and 127.0.0.1:2443 vless raw tcp)
  2. Enable client IP limit on master-node

I use reverse-proxy connection scheme, but other nodes with similar connection thru nginx works fine. I think fail2ban IP limit may affect

Expected behavior

Works without any manual or cron restarting

Actual behavior

Stops listen inbound interfaces

Relevant logs

Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json}
Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: common/errors: The feature gRPC transport (with unnecessary costs, etc.) is deprecated, not recommended for using
Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: common/errors: The feature gRPC transport (with unnecessary costs, etc.) is deprecated, not recommended for usi>
Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: infra/conf: REALITY: Listening on non-443 ports may get your IP blocked by the GFW
Jul 08 08:33:11 /usr/local/x-ui/x-ui[1271697]: INFO - xray core supports the online-stats API; using connection-based onlines and access-log-free IP limit
Jul 08 08:33:21 /usr/local/x-ui/x-ui[1271697]: INFO - [LIMIT_IP] Client client_email: Kept 6 live IPs, queued 1 old IPs for fail2ban
Jul 08 08:39:21 /usr/local/x-ui/x-ui[1271697]: INFO - [LIMIT_IP] Client client_email: Kept 6 live IPs, queued 1 old IPs for fail2ban

Screenshots

Xray running

Pre restart ss out
Pre-restart ss out

After restart ss out
After restart ss out

3x-ui version

3.4.2

Xray-core version

26.6.27

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04.4 LTS

Which parts of the panel are affected?

Statistics / traffic counters, Other

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

Yes — Nginx

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 @aplafoe on GitHub (Jul 8, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5856 ### Describe the bug Time by time Xray stops listen inbounds. `ss -tlnp` doesn't display them. xray logs, x-ui journalctl and dmesg also doesn't provide any helpful info. The web-panel displays xray-core as a normal running state. Restart x-ui service or just xray-core thru web-panel fix it, bit it happens again later ### How to reproduce the problem 1. Create 2 or more Inbounds on slave-node (e.g. 127.0.0.1:1443 vless xhttp and 127.0.0.1:2443 vless raw tcp) 2. Enable client IP limit on master-node I use reverse-proxy connection scheme, but other nodes with similar connection thru nginx works fine. I think fail2ban IP limit may affect ### Expected behavior Works without any manual or cron restarting ### Actual behavior Stops listen inbound interfaces ### Relevant logs ```shell Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json} Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: common/errors: The feature gRPC transport (with unnecessary costs, etc.) is deprecated, not recommended for using Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: common/errors: The feature gRPC transport (with unnecessary costs, etc.) is deprecated, not recommended for usi> Jul 08 08:33:08 /usr/local/x-ui/x-ui[1271697]: WARNING - XRAY: infra/conf: REALITY: Listening on non-443 ports may get your IP blocked by the GFW Jul 08 08:33:11 /usr/local/x-ui/x-ui[1271697]: INFO - xray core supports the online-stats API; using connection-based onlines and access-log-free IP limit Jul 08 08:33:21 /usr/local/x-ui/x-ui[1271697]: INFO - [LIMIT_IP] Client client_email: Kept 6 live IPs, queued 1 old IPs for fail2ban Jul 08 08:39:21 /usr/local/x-ui/x-ui[1271697]: INFO - [LIMIT_IP] Client client_email: Kept 6 live IPs, queued 1 old IPs for fail2ban ``` ### Screenshots <img width="835" height="136" alt="Xray running" src="https://github.com/user-attachments/assets/322d1600-1dd4-4528-89db-845ba6b380e4" /> Pre restart ss out <img width="418" height="262" alt="Pre-restart ss out" src="https://github.com/user-attachments/assets/6732302b-56f4-4202-8826-b2ba48ef0c49" /> After restart ss out <img width="1684" height="316" alt="After restart ss out" src="https://github.com/user-attachments/assets/5edeba6b-8e93-47d8-ac93-5c59db93f5b2" /> ### 3x-ui version 3.4.2 ### Xray-core version 26.6.27 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04.4 LTS ### Which parts of the panel are affected? Statistics / traffic counters, Other ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? Yes — Nginx ### 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:36:54 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 8, 2026):

Investigated in the current source (3x-ui v3.4.2 tag). Summary: the "process is alive but stopped listening" symptom is consistent with two things confirmed in the code, and your suspicion about IP Limit/fail2ban is plausible as the trigger.

1. The panel's "running" status is process-liveness only, not socket health.
internal/xray/process.go IsRunning() only checks that the child OS process hasn't exited (cmd.Process != nil and the done channel isn't closed) — it never probes whether any inbound listener is actually accepting connections. XrayService.DidXrayCrash() (internal/web/service/xray.go:1140) is built directly on that same check, and it's what the automatic recovery job (CheckXrayRunningJob, running every second) uses to decide whether to auto-restart Xray. So a state where the process is alive and the gRPC API inbound still answers, but one or more client-facing inbounds have silently stopped accepting connections, is invisible to both the panel's status display and its auto-restart logic — matching what you observed (panel shows "running", nothing recovers on its own, and ss -tlnp disagrees).

2. IP Limit enforcement does more than write to the fail2ban log — it also force-cycles the client on Xray's own gRPC API.
CheckClientIpJob runs every 10 seconds (internal/web/web.go:291,336). When a client exceeds limitIp and fail2ban is installed/enabled, besides writing the [LIMIT_IP] line fail2ban reads, it calls disconnectClientTemporarily (internal/web/job/check_client_ip_job.go:558), which issues RemoveUser immediately followed by AddUser against Xray's HandlerService (AlterInbound) for that client on the inbound that owns it — independent of whatever fail2ban does at the firewall level. Your log shows the identical Kept 6 live IPs, queued 1 old IPs for fail2ban line recurring several minutes apart, which means the same client stayed over its limit across many of the 10-second scans, so this remove/re-add cycle against that inbound's handler fired repeatedly rather than once.

There is prior history of this exact code path (re-adding a client via the Xray API after an IP-limit disconnect) being fragile specifically for XHTTP inbounds: #4056 was a panic in AddUser triggered from this same call chain on XHTTP clients. That specific panic looks fixed now (the raw type assertions were replaced with getRequiredUserString/getOptionalUserString, and cron jobs are wrapped in cron.Recover, so a panic there would be logged, not crash the panel) — but it shows this mechanism has had real bugs on XHTTP before, and your reproduction steps specifically include a vless+xhttp inbound.

I can't confirm from 3x-ui's source alone whether repeated AlterInbound user churn is what's making Xray-core stop listening on that inbound, since that would be a fault inside Xray-core itself. To narrow it down, could you provide:

  1. Does the issue still occur if you set limitIp to 0 for the affected clients (or temporarily disable/uninstall fail2ban on the slave node) while keeping everything else the same? This would confirm or rule out the IP-limit path as the trigger.
  2. When it happens again, does it affect only the xhttp inbound, only the raw tcp inbound, or both at once? If only one, which.
  3. Xray's own log at debug level (Panel → Xray Configs → log level) captured across the moment the sockets disappear — the journalctl output you posted is at info/warning and may not show the failure itself.
  4. Output of ulimit -n on the slave node, and whether dmesg shows anything (e.g. too many open files) around the failure time.
  5. Whether the slave node's x-ui version matches the master (3.4.2), and whether fail2ban is installed on the slave itself (the [LIMIT_IP] enforcement runs against each panel's own local Xray, so fail2ban needs to be present on the node hosting the inbounds, not just the master).

This reply was generated automatically by an AI agent supervised by the project's maintainers. A human maintainer may follow up.

<!-- gh-comment-id:4913271018 --> @github-actions[bot] commented on GitHub (Jul 8, 2026): Investigated in the current source (3x-ui v3.4.2 tag). Summary: the "process is alive but stopped listening" symptom is consistent with two things confirmed in the code, and your suspicion about IP Limit/fail2ban is plausible as the trigger. **1. The panel's "running" status is process-liveness only, not socket health.** `internal/xray/process.go` `IsRunning()` only checks that the child OS process hasn't exited (`cmd.Process != nil` and the `done` channel isn't closed) — it never probes whether any inbound listener is actually accepting connections. `XrayService.DidXrayCrash()` (`internal/web/service/xray.go:1140`) is built directly on that same check, and it's what the automatic recovery job (`CheckXrayRunningJob`, running every second) uses to decide whether to auto-restart Xray. So a state where the process is alive and the gRPC API inbound still answers, but one or more client-facing inbounds have silently stopped accepting connections, is invisible to both the panel's status display and its auto-restart logic — matching what you observed (panel shows "running", nothing recovers on its own, and `ss -tlnp` disagrees). **2. IP Limit enforcement does more than write to the fail2ban log — it also force-cycles the client on Xray's own gRPC API.** `CheckClientIpJob` runs every 10 seconds (`internal/web/web.go:291,336`). When a client exceeds `limitIp` and fail2ban is installed/enabled, besides writing the `[LIMIT_IP]` line fail2ban reads, it calls `disconnectClientTemporarily` (`internal/web/job/check_client_ip_job.go:558`), which issues `RemoveUser` immediately followed by `AddUser` against Xray's HandlerService (`AlterInbound`) for that client on the inbound that owns it — independent of whatever fail2ban does at the firewall level. Your log shows the identical `Kept 6 live IPs, queued 1 old IPs for fail2ban` line recurring several minutes apart, which means the same client stayed over its limit across many of the 10-second scans, so this remove/re-add cycle against that inbound's handler fired repeatedly rather than once. There is prior history of this exact code path (re-adding a client via the Xray API after an IP-limit disconnect) being fragile specifically for XHTTP inbounds: #4056 was a panic in `AddUser` triggered from this same call chain on XHTTP clients. That specific panic looks fixed now (the raw type assertions were replaced with `getRequiredUserString`/`getOptionalUserString`, and cron jobs are wrapped in `cron.Recover`, so a panic there would be logged, not crash the panel) — but it shows this mechanism has had real bugs on XHTTP before, and your reproduction steps specifically include a `vless`+`xhttp` inbound. I can't confirm from 3x-ui's source alone whether repeated `AlterInbound` user churn is what's making Xray-core stop listening on that inbound, since that would be a fault inside Xray-core itself. To narrow it down, could you provide: 1. Does the issue still occur if you set `limitIp` to `0` for the affected clients (or temporarily disable/uninstall fail2ban on the slave node) while keeping everything else the same? This would confirm or rule out the IP-limit path as the trigger. 2. When it happens again, does it affect only the `xhttp` inbound, only the raw `tcp` inbound, or both at once? If only one, which. 3. Xray's own log at `debug` level (Panel → Xray Configs → log level) captured across the moment the sockets disappear — the journalctl output you posted is at `info`/`warning` and may not show the failure itself. 4. Output of `ulimit -n` on the slave node, and whether `dmesg` shows anything (e.g. `too many open files`) around the failure time. 5. Whether the slave node's `x-ui` version matches the master (3.4.2), and whether fail2ban is installed on the slave itself (the `[LIMIT_IP]` enforcement runs against each panel's own local Xray, so fail2ban needs to be present on the node hosting the inbounds, not just the master). *This reply was generated automatically by an AI agent supervised by the project's maintainers. A human maintainer may follow up.*
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#4067
No description provided.