[GH-ISSUE #6446] [Bug]: Subscription path mismatch after database restore on a clean v3.7.0 installation causes 404 #4363

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

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:

  1. Install 3x-ui v3.7.0 on a clean VPS.
  2. Restore a previously saved database backup through Backup and Restore → Import database.
  3. Open the subscription settings. In the affected installation:
    • Subscription: enabled.
    • Listen IP: empty.
    • Listen domain: empty.
    • Subscription port: 2096.
    • URI path: /custom-path/.
    • Reverse Proxy URI: empty.
    • JSON and Clash/Mihomo subscriptions: disabled.
    • Subscription certificate/key paths are configured.
  4. Copy a restored client's subscription URL from the panel and open it in a browser.
  5. Observe 404 page not found at https://vpn.example.com:2096/custom-path/EXAMPLE_SUB_ID.
  6. Change only /custom-path/ to /sub/, keeping the server, port, scheme, and subscription ID identical.
  7. The subscription information page opens and contains the expected client's two configurations: VLESS TCP REALITY and VLESS XHTTP REALITY.

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

Check Observed result
URI path displayed in panel /custom-path/
Path in copied subscription URL /custom-path/
Browser request to copied URL HTTP 404; body 404 page not found
Same subscription ID under /sub/ Subscription information page with both expected configurations

Relevant logs / diagnostic scope

The failing request was independently reproduced in a browser and returned HTTP 404 with content-type: text/plain and content-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 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

  • Searched existing issues; related report #6281 is linked above.
  • Observed on v3.7.0, the latest stable release when checked.
  • Report written in English.
  • Real server addresses, custom paths, subscription IDs, and client identifiers have been redacted.
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: 1. Install 3x-ui v3.7.0 on a clean VPS. 2. Restore a previously saved database backup through **Backup and Restore → Import database**. 3. Open the subscription settings. In the affected installation: - Subscription: **enabled**. - Listen IP: empty. - Listen domain: empty. - Subscription port: `2096`. - URI path: `/custom-path/`. - Reverse Proxy URI: empty. - JSON and Clash/Mihomo subscriptions: disabled. - Subscription certificate/key paths are configured. 4. Copy a restored client's subscription URL from the panel and open it in a browser. 5. Observe `404 page not found` at `https://vpn.example.com:2096/custom-path/EXAMPLE_SUB_ID`. 6. Change only `/custom-path/` to `/sub/`, keeping the server, port, scheme, and subscription ID identical. 7. The subscription information page opens and contains the expected client's two configurations: VLESS TCP REALITY and VLESS XHTTP REALITY. **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 | Check | Observed result | | --- | --- | | URI path displayed in panel | `/custom-path/` | | Path in copied subscription URL | `/custom-path/` | | Browser request to copied URL | HTTP 404; body `404 page not found` | | Same subscription ID under `/sub/` | Subscription information page with both expected configurations | ### Relevant logs / diagnostic scope The failing request was independently reproduced in a browser and returned HTTP 404 with `content-type: text/plain` and `content-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 - [x] Searched existing issues; related report #6281 is linked above. - [x] Observed on v3.7.0, the latest stable release when checked. - [x] Report written in English. - [x] Real server addresses, custom paths, subscription IDs, and client identifiers have been redacted.
Author
Owner

@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:

x-ui restart

Then hard-reload the panel tab. https://vpn.example.com:2096/custom-path/EXAMPLE_SUB_ID should start working and /sub/ should stop working.

Why it happens

  1. The subscription server reads subPath once, at start-up, and registers exactly one route group from it:

    // internal/sub/sub.go:67
    LinksPath, err := s.settingService.GetSubPath()
    // internal/sub/sub.go:303 -> internal/sub/controller.go:305
    gLink := g.Group(a.subPath)
    gLink.GET(":subid", a.subs)
    

    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.

  2. ServerService.ImportDB swaps the database and then restarts Xray only — never the panel or the subscription server:

    // internal/web/service/server.go:1817-1822
    s.inboundService.MigrateDB()
    
    xrayStopped = false
    if err = s.RestartXrayService(); err != nil {
    

    The controller comment says so outright: // importDB imports a database file and restarts the Xray service. (internal/web/controller/server.go:378).

  3. "Keep this machine's settings" does not cover the subscription path. subURI, subPort, subListen, subCertFile, subKeyFile and webBasePath are all in the host-bound list; subPath is not:

    // internal/web/service/server.go:1622-1628
    "webListen", "webDomain", "webPort", "webCertFile", "webKeyFile", "webBasePath",
    "subListen", "subDomain", "subPort", "subCertFile", "subKeyFile", "subURI", "subJsonURI",
    

    So /custom-path/ from your backup wins in the database regardless of the checkbox.

  4. 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:

    // internal/web/service/setting.go:1634-1638
    subPath, _ := s.GetSubPath()
    ...
    result["subURI"] = subURI + subPath
    
  5. /sub/ is exactly what a clean v3.7.0 install serves: v3.7.0 writes no subPath row at all, so GetSubPath() falls back to "subPath": "/sub/" (internal/web/service/setting.go:132). Random per-install subscription paths only landed later, in f9898e0b ("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 found is 18 characters, matching the content-length: 18 you 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:

// frontend/src/pages/index/BackupModal.tsx:62-69
const restart = await HttpUtil.post('/panel/api/setting/restartPanel');
if (restart?.success) { await PromiseUtil.sleep(5000); window.location.reload(); }

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 users table, and the session is validated against the stored user's login epoch —

// internal/web/session/session.go:80
if !sessionEpochMatches(s.Get(loginEpochKey), user.LoginEpoch) {

— 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 401 with success:false (internal/web/controller/base.go:22), so restartPanel would 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/subKeyFile rows 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 log around the import will show whether a Sub 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.defaults query being cached with staleTime: Infinity and never invalidated after a save; that was fixed in b73ceae0 ("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 from GetSubPath() at start-up (internal/sub/sub.go:67, internal/sub/controller.go:305). Because subPath is absent from hostBoundSettingKeys (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-up POST /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's ImportDB is 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 b73ceae0 and already in v3.7.0)
Evidence: internal/sub/sub.go:67 LinksPath, err := s.settingService.GetSubPath(); internal/sub/controller.go:305 gLink := g.Group(a.subPath); internal/web/service/server.go:1820 if 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, no subPath); internal/web/service/setting.go:132 "subPath": "/sub/"; internal/web/service/setting.go:1638 result["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.go contains no seedRandomSubscriptionPaths, so v3.7.0 fresh installs really do default to /sub/; f9898e0b added that seeding after v3.7.0.
Not determined: Whether the post-import restartPanel call actually failed in your case, and if so why. One check settles it: run x-ui restart and 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 ImportDB trigger the panel restart itself after restoreHostBoundSettings (the same in-process path restartPanel uses via global.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/subClashPath are the only listen-surface settings excluded from hostBoundSettingKeys while webBasePath and subURI are included, which may or may not be intentional.

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

<!-- gh-comment-id:5623381449 --> @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:** ```bash x-ui restart ``` Then hard-reload the panel tab. `https://vpn.example.com:2096/custom-path/EXAMPLE_SUB_ID` should start working and `/sub/` should stop working. ## Why it happens 1. The subscription server reads `subPath` **once**, at start-up, and registers exactly one route group from it: ```go // internal/sub/sub.go:67 LinksPath, err := s.settingService.GetSubPath() // internal/sub/sub.go:303 -> internal/sub/controller.go:305 gLink := g.Group(a.subPath) gLink.GET(":subid", a.subs) ``` 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`. 2. `ServerService.ImportDB` swaps the database and then restarts **Xray only** — never the panel or the subscription server: ```go // internal/web/service/server.go:1817-1822 s.inboundService.MigrateDB() xrayStopped = false if err = s.RestartXrayService(); err != nil { ``` The controller comment says so outright: `// importDB imports a database file and restarts the Xray service.` (`internal/web/controller/server.go:378`). 3. "Keep this machine's settings" does **not** cover the subscription path. `subURI`, `subPort`, `subListen`, `subCertFile`, `subKeyFile` and `webBasePath` are all in the host-bound list; `subPath` is not: ```go // internal/web/service/server.go:1622-1628 "webListen", "webDomain", "webPort", "webCertFile", "webKeyFile", "webBasePath", "subListen", "subDomain", "subPort", "subCertFile", "subKeyFile", "subURI", "subJsonURI", ``` So `/custom-path/` from your backup wins in the database regardless of the checkbox. 4. 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: ```go // internal/web/service/setting.go:1634-1638 subPath, _ := s.GetSubPath() ... result["subURI"] = subURI + subPath ``` 5. `/sub/` is exactly what a clean **v3.7.0** install serves: v3.7.0 writes no `subPath` row at all, so `GetSubPath()` falls back to `"subPath": "/sub/"` (`internal/web/service/setting.go:132`). Random per-install subscription paths only landed later, in `f9898e0b` ("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 found` is 18 characters, matching the `content-length: 18` you 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: ```ts // frontend/src/pages/index/BackupModal.tsx:62-69 const restart = await HttpUtil.post('/panel/api/setting/restartPanel'); if (restart?.success) { await PromiseUtil.sleep(5000); window.location.reload(); } ``` 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 `users` table, and the session is validated against the stored user's login epoch — ```go // internal/web/session/session.go:80 if !sessionEpochMatches(s.Get(loginEpochKey), user.LoginEpoch) { ``` — 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 `401` with `success:false` (`internal/web/controller/base.go:22`), so `restartPanel` would 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`/`subKeyFile` rows 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 log` around the import will show whether a `Sub 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.defaults` query being cached with `staleTime: Infinity` and never invalidated after a save; that was fixed in `b73ceae0` ("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 from `GetSubPath()` at start-up (`internal/sub/sub.go:67`, `internal/sub/controller.go:305`). Because `subPath` is absent from `hostBoundSettingKeys` (`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-up `POST /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`'s `ImportDB` is 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 `b73ceae0` and already in v3.7.0) Evidence: `internal/sub/sub.go:67` `LinksPath, err := s.settingService.GetSubPath()`; `internal/sub/controller.go:305` `gLink := g.Group(a.subPath)`; `internal/web/service/server.go:1820` `if 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, no `subPath`); `internal/web/service/setting.go:132` `"subPath": "/sub/"`; `internal/web/service/setting.go:1638` `result["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.go` contains no `seedRandomSubscriptionPaths`, so v3.7.0 fresh installs really do default to `/sub/`; `f9898e0b` added that seeding after v3.7.0. Not determined: Whether the post-import `restartPanel` call actually failed in your case, and if so why. One check settles it: run `x-ui restart` and 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 `ImportDB` trigger the panel restart itself after `restoreHostBoundSettings` (the same in-process path `restartPanel` uses via `global.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`/`subClashPath` are the only listen-surface settings excluded from `hostBoundSettingKeys` while `webBasePath` and `subURI` are included, which may or may not be intentional. *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#4363
No description provided.