[GH-ISSUE #4056] [Bug] Panel crashes on panic when CheckClientIpJob tries to disconnect clients with limitIp > 0 on XHTTP inbounds #2751

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

Originally created by @Teskatlipoka on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4056

Describe the bug

Description
After upgrading from v2.8.11 to v2.9.0, the panel enters a permanent crashloop. The process panics every ~20–25 seconds (each time CheckClientIpJob runs as a cron task), exits with code 2, is restarted by systemd, and panics again. Xray itself starts correctly and handles traffic during the brief windows when the panel is up, but the cycle repeats indefinitely.
The issue is not related to the Xray config itself — xray -test -config bin/config.json reports Configuration OK. The panic occurs in the panel's Go code.
Environment / Configuration
The server has two inbounds:

Inbound 1: VLESS + Reality + flow: xtls-rprx-vision, 1 client with limitIp = 2
Inbound 3: VLESS + XHTTP + TLS, 13 clients, most with limitIp = 1 or limitIp = 2 (no flow field, which is correct for XHTTP)

All 14 clients have valid, non-empty email, id, and subId fields. Example client object (from the DB):
{
"comment": "",
"created_at": 1773844435000,
"email": "",
"enable": true,
"expiryTime": 0,
"flow": "",
"id": "",
"limitIp": 2,
"reset": 0,
"subId": "",
"tgId": "",
"totalGB": 0,
"updated_at": 1776722374000
}

How to repeat the problem?

Steps to reproduce

Have at least one VLESS + XHTTP + TLS inbound with clients that have limitIp > 0.
Have those clients actively using the VPN from multiple IPs (so that access.log contains entries where the unique IP count per client exceeds limitIp).
Upgrade from v2.8.11 to v2.9.0 via the menu (option 2, Update).
Observe the panel crashlooping every ~20–25 seconds.

Expected behavior
Panel should stay up and properly disconnect/reconnect clients that exceed their IP limit, as in v2.8.11.
Actual behavior
Panel panics and exits every time CheckClientIpJob fires. Crash is deterministic as long as there is at least one client with limitIp > 0 whose unique IP count in the access log exceeds the limit.
Panic stack trace

panic: interface conversion: interface {} is nil, not string

goroutine 88 [running]:
github.com/mhsanaei/3x-ui/v2/xray.(*XrayAPI).AddUser(...)
/home/runner/work/3x-ui/3x-ui/xray/api.go:116 +0xaf9
github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).disconnectClientTemporarily(...)
/home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:451 +0x645
github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).updateInboundClientIps(...)
/home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:364 +0xf05
github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).processLogFile(...)
/home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:199 +0x6e5
github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).Run(...)
/home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:62 +0xa5
github.com/robfig/cron/v3.(*Cron).startJob.func1()
/home/runner/go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:312 +0x55
created by github.com/robfig/cron/v3.(*Cron).startJob in goroutine 12
/home/runner/go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:310 +0x8c

systemd[1]: x-ui.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

Root cause (hypothesis)
In xray/api.go:116, inside AddUser, a type assertion .(string) is performed on a value from the client config map that can be nil (rather than an empty string) for clients on XHTTP inbounds. This triggers the panic interface conversion: interface {} is nil, not string.
The call chain that reaches this code path runs only when CheckClientIpJob detects a client whose actual connection count exceeds its limitIp and calls disconnectClientTemporarily → AddUser (to re-add the client after disconnection). If no client is over its limit, the crash is not triggered.
Workaround
Setting limitIp = 0 for all clients prevents CheckClientIpJob from ever calling disconnectClientTemporarily, which avoids the panic entirely. The panel then runs stably on v2.9.0.
SQL to apply the workaround (stop the panel first):

UPDATE inbounds
SET settings = (
SELECT json_set(
settings,
'$.clients',
(SELECT json_group_array(json_set(value, '$.limitIp', 0))
FROM json_each(settings, '$.clients'))
)
);

This of course disables IP-limit enforcement, so it is only suitable as a temporary mitigation.
Additional notes

The issue is reproducible on multiple servers with similar setups (XHTTP + TLS inbounds with limitIp > 0).
Servers with only Reality + Vision inbounds (where flow is always non-empty on clients) do not appear to be affected — possibly because the same code path in AddUser reads a different, always-string field for those clients.
Downgrading to v2.8.11 fully resolves the crash without any data loss.

Expected action

No response

Received action

No response

3x-ui Version

2.9.0

Xray-core Version

26.4.17

Checklist

  • This bug report is written entirely in English.
  • This bug report is new and no one has reported it before me.
Originally created by @Teskatlipoka on GitHub (Apr 21, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4056 ### Describe the bug Description After upgrading from v2.8.11 to v2.9.0, the panel enters a permanent crashloop. The process panics every ~20–25 seconds (each time CheckClientIpJob runs as a cron task), exits with code 2, is restarted by systemd, and panics again. Xray itself starts correctly and handles traffic during the brief windows when the panel is up, but the cycle repeats indefinitely. The issue is not related to the Xray config itself — xray -test -config bin/config.json reports Configuration OK. The panic occurs in the panel's Go code. Environment / Configuration The server has two inbounds: Inbound 1: VLESS + Reality + flow: xtls-rprx-vision, 1 client with limitIp = 2 Inbound 3: VLESS + XHTTP + TLS, 13 clients, most with limitIp = 1 or limitIp = 2 (no flow field, which is correct for XHTTP) All 14 clients have valid, non-empty email, id, and subId fields. Example client object (from the DB): { "comment": "", "created_at": 1773844435000, "email": "<non-empty>", "enable": true, "expiryTime": 0, "flow": "", "id": "<valid-uuid>", "limitIp": 2, "reset": 0, "subId": "<non-empty>", "tgId": "", "totalGB": 0, "updated_at": 1776722374000 } ### How to repeat the problem? Steps to reproduce Have at least one VLESS + XHTTP + TLS inbound with clients that have limitIp > 0. Have those clients actively using the VPN from multiple IPs (so that access.log contains entries where the unique IP count per client exceeds limitIp). Upgrade from v2.8.11 to v2.9.0 via the menu (option 2, Update). Observe the panel crashlooping every ~20–25 seconds. Expected behavior Panel should stay up and properly disconnect/reconnect clients that exceed their IP limit, as in v2.8.11. Actual behavior Panel panics and exits every time CheckClientIpJob fires. Crash is deterministic as long as there is at least one client with limitIp > 0 whose unique IP count in the access log exceeds the limit. Panic stack trace panic: interface conversion: interface {} is nil, not string goroutine 88 [running]: github.com/mhsanaei/3x-ui/v2/xray.(*XrayAPI).AddUser(...) /home/runner/work/3x-ui/3x-ui/xray/api.go:116 +0xaf9 github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).disconnectClientTemporarily(...) /home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:451 +0x645 github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).updateInboundClientIps(...) /home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:364 +0xf05 github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).processLogFile(...) /home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:199 +0x6e5 github.com/mhsanaei/3x-ui/v2/web/job.(*CheckClientIpJob).Run(...) /home/runner/work/3x-ui/3x-ui/web/job/check_client_ip_job.go:62 +0xa5 github.com/robfig/cron/v3.(*Cron).startJob.func1() /home/runner/go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:312 +0x55 created by github.com/robfig/cron/v3.(*Cron).startJob in goroutine 12 /home/runner/go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:310 +0x8c systemd[1]: x-ui.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Root cause (hypothesis) In xray/api.go:116, inside AddUser, a type assertion .(string) is performed on a value from the client config map that can be nil (rather than an empty string) for clients on XHTTP inbounds. This triggers the panic interface conversion: interface {} is nil, not string. The call chain that reaches this code path runs only when CheckClientIpJob detects a client whose actual connection count exceeds its limitIp and calls disconnectClientTemporarily → AddUser (to re-add the client after disconnection). If no client is over its limit, the crash is not triggered. Workaround Setting limitIp = 0 for all clients prevents CheckClientIpJob from ever calling disconnectClientTemporarily, which avoids the panic entirely. The panel then runs stably on v2.9.0. SQL to apply the workaround (stop the panel first): UPDATE inbounds SET settings = ( SELECT json_set( settings, '$.clients', (SELECT json_group_array(json_set(value, '$.limitIp', 0)) FROM json_each(settings, '$.clients')) ) ); This of course disables IP-limit enforcement, so it is only suitable as a temporary mitigation. Additional notes The issue is reproducible on multiple servers with similar setups (XHTTP + TLS inbounds with limitIp > 0). Servers with only Reality + Vision inbounds (where flow is always non-empty on clients) do not appear to be affected — possibly because the same code path in AddUser reads a different, always-string field for those clients. Downgrading to v2.8.11 fully resolves the crash without any data loss. ### Expected action _No response_ ### Received action _No response_ ### 3x-ui Version 2.9.0 ### Xray-core Version 26.4.17 ### Checklist - [x] This bug report is written entirely in English. - [x] This bug report is new and no one has reported it before me.
bsakaguchi 2026-10-31 20:27:40 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@DParadoxus commented on GitHub (Apr 21, 2026):

same problem

<!-- gh-comment-id:4286368581 --> @DParadoxus commented on GitHub (Apr 21, 2026): same problem
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#2751
No description provided.