[GH-ISSUE #5712] [Bug] Panel stops completely and XHTTP connection closes after updating to v3.4.2 & showing the crash and cookie error #3975

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

Originally created by @tradeahadi-cmyk on GitHub (Jul 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5712

Describe the bug

Description:
Hello,
After updating the panel to version 3.4.2, I am experiencing critical issues where the core completely stops working. There seem to be two connected problems: a session/cookie error in the panel and a network connection drop related to XHTTP on port 443.

Steps to Reproduce:

Update the panel to version 3.4.2.

Have an active XHTTP inbound configuration on port 443.

Check the panel logs and Xray logs after a short period.

The core eventually stops completely following the securecookie error.

Expected Behavior:
The panel should maintain active sessions without stopping the core, and the XHTTP inbound on port 443 should remain stable and continue serving traffic without closing the network connection.

Error Logs:

Panel/System Logs (showing the crash and cookie error):
Plaintext

Jul 01 10:16:51 tun /usr/local/x-ui/x-ui[1663]: INFO - Remove Inbound User [Username] due to expiration or traffic limit
Jul 01 10:24:25 tun x-ui[1663]: 2026/07/01 10:24:25 ERROR [sessions] ERROR! err="securecookie: the value is not valid"
Jul 01 10:24:25 tun x-ui[1663]: 2026/07/01 10:24:25 ERROR [sessions] ERROR! err="securecookie: the value is not valid"

Xray Logs (showing the XHTTP drop):
Plaintext

2026/07/01 09:50:03 ERROR - XRAY: transport/internet/splithttp: failed to serve HTTP for XHTTP > accept tcp [::]:443: use of closed network connection

Environment:

Panel Version: 3.4.2

Inbound Protocol: XHTTP (Port 443)

Any guidance or a hotfix for this issue would be greatly appreciated.

How to reproduce the problem

Update the panel to version 3.4.2.

Have an active XHTTP inbound configuration on port 443.

Check the panel logs and Xray logs after a short period.

The core eventually stops completely following the securecookie error.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.4.2

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

ubuntu24

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

chrome

Is the panel behind a reverse proxy or CDN?

None

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 @tradeahadi-cmyk on GitHub (Jul 1, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5712 ### Describe the bug Description: Hello, After updating the panel to version 3.4.2, I am experiencing critical issues where the core completely stops working. There seem to be two connected problems: a session/cookie error in the panel and a network connection drop related to XHTTP on port 443. Steps to Reproduce: Update the panel to version 3.4.2. Have an active XHTTP inbound configuration on port 443. Check the panel logs and Xray logs after a short period. The core eventually stops completely following the securecookie error. Expected Behavior: The panel should maintain active sessions without stopping the core, and the XHTTP inbound on port 443 should remain stable and continue serving traffic without closing the network connection. Error Logs: Panel/System Logs (showing the crash and cookie error): Plaintext Jul 01 10:16:51 tun /usr/local/x-ui/x-ui[1663]: INFO - Remove Inbound User [Username] due to expiration or traffic limit Jul 01 10:24:25 tun x-ui[1663]: 2026/07/01 10:24:25 ERROR [sessions] ERROR! err="securecookie: the value is not valid" Jul 01 10:24:25 tun x-ui[1663]: 2026/07/01 10:24:25 ERROR [sessions] ERROR! err="securecookie: the value is not valid" Xray Logs (showing the XHTTP drop): Plaintext 2026/07/01 09:50:03 ERROR - XRAY: transport/internet/splithttp: failed to serve HTTP for XHTTP > accept tcp [::]:443: use of closed network connection Environment: Panel Version: 3.4.2 Inbound Protocol: XHTTP (Port 443) Any guidance or a hotfix for this issue would be greatly appreciated. ### How to reproduce the problem Update the panel to version 3.4.2. Have an active XHTTP inbound configuration on port 443. Check the panel logs and Xray logs after a short period. The core eventually stops completely following the securecookie error. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.4.2 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system ubuntu24 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) chrome ### Is the panel behind a reverse proxy or CDN? None ### 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:16 +07:00
Author
Owner

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

The XHTTP disconnect and the panel session/cookie error are two independent code paths. Xray-core runs as a separate managed child process from the panels web server (internal/xray/process.go), so a session-cookie problem in the panel cannot itself crash or restart Xray.

XHTTP "use of closed network connection" on port 443

This is very likely explained by the Restart Xray After Auto Disable setting (Settings General; key restartXrayOnClientDisable, enabled by default confirmed in internal/web/service/setting.go). When a client expires or hits its traffic limit, XrayTrafficJob.Run() (internal/web/job/xray_traffic_job.go:39-58), which polls every 5 seconds (cadenceXrayTraffic = "@every 5s" in internal/web/web.go), calls xrayService.RestartXray(true).

In RestartXray (internal/web/service/xray.go:939-971), isForce=true always takes the "stop the running process, then start a brand-new one" path. The API-based hot reload (tryHotApply, which can apply added/removed clients through Xrays gRPC API without touching any listener) is only attempted when the restart is not forced. A full process stop closes every listener, including the XHTTP inbound on port 443 which is exactly what produces failed to serve HTTP for XHTTP ... use of closed network connection: any in-flight Accept() on that socket errors the moment it is closed. This auto-restart mechanism was added 2026-05-04, so it predates 3.4.2, but if clients are regularly expiring or hitting traffic limits on your panel, it will force a full Xray restart (and drop the XHTTP listener) on every such event.

To confirm and mitigate:

  • Turn off Restart Xray After Auto Disable in Settings General and see if the XHTTP drops stop.
  • Please confirm whether Xray actually stays down after that log line, or comes back up immediately (check the x-ui menu Xray status, or systemctl status x-ui). The log line itself is an expected, transient side effect of any restart; if the core does NOT come back afterward, that points to a separate startup failure and we would need the Xray stdout/stderr right after that line.

securecookie: the value is not valid

This error means the cookie-session library failed to verify a cookies signature; it only affects panel logins, not Xray/XHTTP. The signing key is read once at startup from the secret row in the settings table (SettingService.GetSecret, internal/web/service/setting.go:634-643), generated once and persisted to the database a normal panel restart reuses the same key and should not invalidate existing session cookies. We found no change to the session/cookie code in the 3.4.x releases (the last logic change to internal/web/session/session.go predates 3.4.0), so we cannot confirm this is a new regression in 3.4.2 versus a pre-existing or environmental condition.

To narrow it down, please provide:

  1. Whether this is the same, continuously-used SQLite database from before the update, or whether the database/volume was recreated during the upgrade.
  2. Whether more than one x-ui process/node is involved (multi-node sync, a container recreated with a fresh volume, a load balancer in front of the panel) that could issue cookies signed with different secrets.
  3. Whether logging out, clearing the 3x-ui cookie, and logging back in resolves it, or it recurs continuously on an already-open session.
  4. Full, uninterrupted panel logs spanning both the XHTTP drop and the securecookie errors with real timestamps, so we can see whether the two are actually correlated or coincidental.

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

<!-- gh-comment-id:4853465582 --> @github-actions[bot] commented on GitHub (Jul 1, 2026): The XHTTP disconnect and the panel session/cookie error are two independent code paths. Xray-core runs as a separate managed child process from the panels web server (`internal/xray/process.go`), so a session-cookie problem in the panel cannot itself crash or restart Xray. **XHTTP "use of closed network connection" on port 443** This is very likely explained by the `Restart Xray After Auto Disable` setting (Settings General; key `restartXrayOnClientDisable`, **enabled by default** confirmed in `internal/web/service/setting.go`). When a client expires or hits its traffic limit, `XrayTrafficJob.Run()` (`internal/web/job/xray_traffic_job.go:39-58`), which polls every 5 seconds (`cadenceXrayTraffic = "@every 5s"` in `internal/web/web.go`), calls `xrayService.RestartXray(true)`. In `RestartXray` (`internal/web/service/xray.go:939-971`), `isForce=true` always takes the "stop the running process, then start a brand-new one" path. The API-based hot reload (`tryHotApply`, which can apply added/removed clients through Xrays gRPC API without touching any listener) is only attempted when the restart is not forced. A full process stop closes every listener, including the XHTTP inbound on port 443 which is exactly what produces `failed to serve HTTP for XHTTP ... use of closed network connection`: any in-flight `Accept()` on that socket errors the moment it is closed. This auto-restart mechanism was added 2026-05-04, so it predates 3.4.2, but if clients are regularly expiring or hitting traffic limits on your panel, it will force a full Xray restart (and drop the XHTTP listener) on every such event. To confirm and mitigate: - Turn off `Restart Xray After Auto Disable` in Settings General and see if the XHTTP drops stop. - Please confirm whether Xray actually stays down after that log line, or comes back up immediately (check the `x-ui` menu Xray status, or `systemctl status x-ui`). The log line itself is an expected, transient side effect of any restart; if the core does NOT come back afterward, that points to a separate startup failure and we would need the Xray stdout/stderr right after that line. **`securecookie: the value is not valid`** This error means the cookie-session library failed to verify a cookies signature; it only affects panel logins, not Xray/XHTTP. The signing key is read once at startup from the `secret` row in the settings table (`SettingService.GetSecret`, `internal/web/service/setting.go:634-643`), generated once and persisted to the database a normal panel restart reuses the same key and should not invalidate existing session cookies. We found no change to the session/cookie code in the 3.4.x releases (the last logic change to `internal/web/session/session.go` predates 3.4.0), so we cannot confirm this is a new regression in 3.4.2 versus a pre-existing or environmental condition. To narrow it down, please provide: 1. Whether this is the same, continuously-used SQLite database from before the update, or whether the database/volume was recreated during the upgrade. 2. Whether more than one x-ui process/node is involved (multi-node sync, a container recreated with a fresh volume, a load balancer in front of the panel) that could issue cookies signed with different secrets. 3. Whether logging out, clearing the `3x-ui` cookie, and logging back in resolves it, or it recurs continuously on an already-open session. 4. Full, uninterrupted panel logs spanning both the XHTTP drop and the `securecookie` errors with real timestamps, so we can see whether the two are actually correlated or coincidental. *This reply was generated automatically and a maintainer may follow up.*
Author
Owner

@tradeahadi-cmyk commented on GitHub (Jul 1, 2026):

Thank you for the incredibly detailed analysis. You are completely right, and this perfectly explains the behavior I am seeing.

Regarding the XHTTP / "use of closed network connection" issue:

  • I will disable the Restart Xray After Auto Disable setting to confirm the connection drops stop.
  • To answer your question: the core does come back up immediately after the log line; it doesn't stay down permanently.
  • Given my server environment (a 2-core CPU, 2GB RAM instance handling around 100 concurrent users), these full process restarts are quite disruptive to active XHTTP connections. Are there any plans to handle traffic limits and user expirations via the gRPC API (tryHotApply) instead of a forced process restart in future releases?

Regarding the securecookie error:
Your suspicion about multiple nodes is spot on and explains everything.

  • This is not a standard, single-instance SQLite setup. The architecture is a master-node configuration utilizing a PostgreSQL database.
  • Because multiple nodes are involved, it is highly likely the instances are not properly sharing the same secret for cookie signatures, or the traffic routing between the master and nodes is invalidating the sessions.

I will monitor the panel after adjusting the settings and test clearing the cookies to see if the session stabilizes across the nodes.

Thanks again for pointing me in the exact right direction!

<!-- gh-comment-id:4853506527 --> @tradeahadi-cmyk commented on GitHub (Jul 1, 2026): Thank you for the incredibly detailed analysis. You are completely right, and this perfectly explains the behavior I am seeing. Regarding the **XHTTP / "use of closed network connection"** issue: * I will disable the `Restart Xray After Auto Disable` setting to confirm the connection drops stop. * To answer your question: the core does come back up immediately after the log line; it doesn't stay down permanently. * Given my server environment (a 2-core CPU, 2GB RAM instance handling around 100 concurrent users), these full process restarts are quite disruptive to active XHTTP connections. Are there any plans to handle traffic limits and user expirations via the gRPC API (`tryHotApply`) instead of a forced process restart in future releases? Regarding the **`securecookie`** error: Your suspicion about multiple nodes is spot on and explains everything. * This is **not** a standard, single-instance SQLite setup. The architecture is a master-node configuration utilizing a **PostgreSQL** database. * Because multiple nodes are involved, it is highly likely the instances are not properly sharing the same `secret` for cookie signatures, or the traffic routing between the master and nodes is invalidating the sessions. I will monitor the panel after adjusting the settings and test clearing the cookies to see if the session stabilizes across the nodes. Thanks again for pointing me in the exact right direction!
Author
Owner

@MHSanaei commented on GitHub (Jul 2, 2026):

Fixed in e5b56c94, directly addressing your follow-up question: client expirations and traffic-limit disables are now reconciled through the Xray gRPC API instead of a forced process restart. The disable path already removed the user from the running core; the redundant full restart that killed every live connection (your XHTTP drops on 443) is gone, and the config re-sync now happens as per-user API operations for VLESS/VMess/Trojan inbounds without touching any listener. Restart Xray After Auto Disable still works as the on/off switch for the reconcile.

The securecookie errors are, as you confirmed, your multi-node/PostgreSQL topology issuing cookies signed with different secrets — not a panel bug. Make sure all panel instances serving the same hostname share one database (one secret row), or pin sessions to one instance at the load balancer. Will ship in the next release.

<!-- gh-comment-id:4863445343 --> @MHSanaei commented on GitHub (Jul 2, 2026): Fixed in e5b56c94, directly addressing your follow-up question: client expirations and traffic-limit disables are now reconciled through the Xray gRPC API instead of a forced process restart. The disable path already removed the user from the running core; the redundant full restart that killed every live connection (your XHTTP drops on 443) is gone, and the config re-sync now happens as per-user API operations for VLESS/VMess/Trojan inbounds without touching any listener. `Restart Xray After Auto Disable` still works as the on/off switch for the reconcile. The securecookie errors are, as you confirmed, your multi-node/PostgreSQL topology issuing cookies signed with different secrets — not a panel bug. Make sure all panel instances serving the same hostname share one database (one `secret` row), or pin sessions to one instance at the load balancer. Will ship in the next release.
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#3975
No description provided.