mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6446] [Bug]: Subscription path mismatch after database restore on a clean v3.7.0 installation causes 404 #4363
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4363
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Kijomimi on GitHub (Sep 10, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6446
Describe the bug
After a clean installation of 3x-ui v3.7.0 on a new VPS and restoring a previously saved database backup through the panel's Backup and Restore → Import database dialog, the subscription URL shown/copied by the panel returns
404 page not found.The subscription is enabled. The panel's subscription settings show a custom URI path, and the copied subscription URL uses that same custom path. However, replacing only that path with
/sub/successfully opens the subscription information page for the same client, including both VLESS configurations.All server addresses, custom paths, and subscription IDs below are anonymized examples.
How to reproduce the problem
This is the sequence that led to the observed failure; it has not yet been repeated on a second clean installation:
2096./custom-path/.404 page not foundathttps://vpn.example.com:2096/custom-path/EXAMPLE_SUB_ID./custom-path/to/sub/, keeping the server, port, scheme, and subscription ID identical.Restore option context: The supplied screenshot of the import dialog shows Keep this machine's settings checked. Its description says it preserves the current machine's panel addresses/ports, base path, certificates, and node credentials instead of those in the imported file. The option's exact state at the earlier import submission was not independently captured. Please consider the interaction between preserved machine settings, restored subscription settings, and frontend cached settings when reproducing.
Expected behavior
After restoring the database, the subscription path displayed in settings, the generated subscription URL, and the path served by the subscription listener should agree. If a restart or full browser reload is required, the restore flow should make that requirement explicit and avoid presenting an unusable URL as ready to use.
Actual behavior
/custom-path//custom-path/404 page not found/sub/Relevant logs / diagnostic scope
The failing request was independently reproduced in a browser and returned HTTP 404 with
content-type: text/plainandcontent-length: 18.Server logs and a direct database inspection are not available. The effect of restarting the panel or hard-reloading the panel tab has not been verified. Therefore, stale listener configuration, stale frontend state, or restore/preserve-settings behavior are possible explanations, not a confirmed root cause.
3x-ui version
v3.7.0 (latest stable GitHub release when checked).
Xray-core version
Not collected.
How did you install 3x-ui?
Clean installation on a new VPS, followed by importing a saved database backup through the panel. The exact installation method and the version that originally created the backup have not been collected.
Operating system
VPS distribution/version not collected.
Which parts of the panel are affected?
Subscription; database backup/restore; settings and generated subscription URLs.
Browser
Google Chrome on macOS; exact browser version not collected.
Reverse proxy / CDN
The affected URLs were accessed directly via the VPS IP and port. The panel's subscription Reverse Proxy URI field is empty.
Related issue
Related to #6281, which was closed and described the opposite direction of path mismatch after changing settings: the frontend retained
/sub/, while the custom backend path worked. This report concerns clean installation + database restoration on v3.7.0, with the custom path shown in the panel failing while/sub/works. A shared underlying frontend-state issue has not been ruled out.Before submitting
@github-actions[bot] commented on GitHub (Sep 10, 2026):
Confirmed bug, and your instinct about "stale listener configuration" is the right one: after a database import the panel reads the imported subscription path straight out of the database, while the process that actually serves subscriptions is still bound to the routes it registered when the panel booted. Restoring a database does not restart the subscription listener.
Fix it on your server right now:
Then hard-reload the panel tab.
https://vpn.example.com:2096/custom-path/EXAMPLE_SUB_IDshould start working and/sub/should stop working.Why it happens
The subscription server reads
subPathonce, at start-up, and registers exactly one route group from it:Nothing re-reads it afterwards. The only thing that rebuilds the listener is a panel restart (SIGHUP), which recreates the server in
main.go:186-192.ServerService.ImportDBswaps the database and then restarts Xray only — never the panel or the subscription server:The controller comment says so outright:
// importDB imports a database file and restarts the Xray service.(internal/web/controller/server.go:378)."Keep this machine's settings" does not cover the subscription path.
subURI,subPort,subListen,subCertFile,subKeyFileandwebBasePathare all in the host-bound list;subPathis not:So
/custom-path/from your backup wins in the database regardless of the checkbox.The panel then composes the copied URL live from that database value, which is why the settings page and the copy button agree with each other and disagree with the server:
/sub/is exactly what a clean v3.7.0 install serves: v3.7.0 writes nosubPathrow at all, soGetSubPath()falls back to"subPath": "/sub/"(internal/web/service/setting.go:132). Random per-install subscription paths only landed later, inf9898e0b("fix(sub): randomize fresh panel subscription paths", #6375), which is not in v3.7.0.That accounts for every row of your table, including the response itself:
404 page not foundis 18 characters, matching thecontent-length: 18you measured — the router's own not-found body, so the request did reach the subscription listener on 2096 and simply matched no registered route there.The one piece I could not confirm
The panel is supposed to restart itself after an import — the browser fires a follow-up call:
If that call fails, it is a silent no-op — no restart, no reload. The most likely reason it failed for you (an inference, not something I can verify from your report): the import replaced the
userstable, and the session is validated against the stored user's login epoch —— which the imported row will not match if the admin on the source panel had ever changed their password or enabled 2FA. An unauthenticated AJAX POST returns
401withsuccess:false(internal/web/controller/base.go:22), sorestartPanelwould have quietly done nothing while the import itself reported success.A side observation that points the same way: with "Keep this machine's settings" checked on a machine that had no subscription certificate of its own, the imported
subCertFile/subKeyFilerows are deleted (internal/web/service/server.go:1678). You report those paths as configured, so either the box was not checked when you submitted, or you set them after the import — worth knowing when reproducing.If you still have the panel log from that day,
x-ui logaround the import will show whether aSub server running HTTP…line was printed after it (internal/sub/sub.go:391/397). No such line after the import confirms the restart never fired.On #6281
Related, not the same defect. #6281 was the frontend's
settings.defaultsquery being cached withstaleTime: Infinityand never invalidated after a save; that was fixed inb73ceae0("fix(frontend): refresh subscription settings after save", #6287), which is in v3.7.0. Here the frontend is showing the correct, current database value — it is the server side that is stale, so the mismatch runs in the opposite direction, as you noted.Verdict: Confirmed bug
Severity: Medium
Confidence: Medium
Root cause:
ServerService.ImportDB(internal/web/service/server.go:1701-1830) restarts only Xray (line 1820) and never the subscription server, whose routes are registered once fromGetSubPath()at start-up (internal/sub/sub.go:67,internal/sub/controller.go:305). BecausesubPathis absent fromhostBoundSettingKeys(server.go:1622-1628), an import always rewrites it, so the panel serves the pre-import path while displaying and handing out the imported one. Triggered whenever the browser's follow-upPOST /panel/api/setting/restartPanel(frontend/src/pages/index/BackupModal.tsx:63) does not succeed — that call is the only thing that restarts the listener, and it fails silently.Already fixed: Still present on the default branch —
main'sImportDBis byte-identical to v3.7.0's in this respect (git show v3.7.0:internal/web/service/server.go, restart section unchanged).Duplicate of: Related: #6281 (same symptom class, different layer — that one was the frontend defaults cache, fixed by
b73ceae0and already in v3.7.0)Evidence:
internal/sub/sub.go:67LinksPath, err := s.settingService.GetSubPath();internal/sub/controller.go:305gLink := g.Group(a.subPath);internal/web/service/server.go:1820if err = s.RestartXrayService(); err != nil {;internal/web/controller/server.go:378// importDB imports a database file and restarts the Xray service.;internal/web/service/server.go:1622-1628(host-bound key list, nosubPath);internal/web/service/setting.go:132"subPath": "/sub/";internal/web/service/setting.go:1638result["subURI"] = subURI + subPath;main.go:186-192(SIGHUP is the only path that rebuilds the sub server);git show v3.7.0:internal/database/db.gocontains noseedRandomSubscriptionPaths, so v3.7.0 fresh installs really do default to/sub/;f9898e0badded that seeding after v3.7.0.Not determined: Whether the post-import
restartPanelcall actually failed in your case, and if so why. One check settles it: runx-ui restartand reload the panel — if/custom-path/then serves the subscription and/sub/starts returning 404, the listener was stale and the diagnosis above holds.Suggested fix: Have
ImportDBtrigger the panel restart itself afterrestoreHostBoundSettings(the same in-process pathrestartPaneluses viaglobal.TriggerRestart), so the restart is not contingent on a browser follow-up that can 401 on the session the import just invalidated. Separately worth a maintainer decision, not part of the fix:subPath/subJsonPath/subClashPathare the only listen-surface settings excluded fromhostBoundSettingKeyswhilewebBasePathandsubURIare included, which may or may not be intentional.This reply was generated automatically; a maintainer may follow up.