mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6324] [Bug]: "Request failed with status code 403" when logging in to the panel #4294
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#4294
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 @Rockst4r4 on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6324
Describe the bug
Request failed with status code 403
Im reciving this error when im tring to login to console
How to reproduce the problem
Request failed with status code 403
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
ubuntu 24
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No response
Before submitting
@github-actions[bot] commented on GitHub (Aug 25, 2026):
I could not evaluate this report as filed — a
403on login has three distinct sources in v3.7.0 and the issue contains nothing that tells them apart. But one detail in your report is a concrete lead, so please read the first section before answering the questions at the bottom.The error string you quoted cannot come from a v3.7.0 panel
The exact wording matters here. v3.7.0's UI builds its error message as:
That is
Request failed with status 403— nocode. The wording you quoted,Request failed with status code 403, is axios's message format, and axios was removed from this project in commitbc309ed9("refactor(frontend): replace axios with the native Fetch API"), which first shipped in v3.5.0. The last release that bundled axios is v3.4.2 (frontend/package.json:30:"axios": "^1.18.1"), and a repo-wide search finds no axios anywhere on the current default branch.So either the panel actually running is v3.4.2 or older, or the message is coming from a different client (a third-party manager app, a script) rather than the panel's own login page. Please confirm with:
What actually returns 403 on the login path in v3.7.0
Worth stating up front: a wrong username or password never produces a 403. Both the credential check and the brute-force limiter answer with HTTP 200 and a JSON error body (
internal/web/controller/index.go:91and:111). A 403 means the request was rejected before your credentials were ever looked at. Only three things can do that:The CSRF check on
POST /<basePath>/login(internal/web/controller/index.go:46wiresmiddleware.CSRFMiddleware()onto the route). It aborts with a bare, empty-bodied 403:ValidateCSRFToken(internal/web/session/csrf.go:33-47) compares theX-CSRF-Tokenheader against the token stored in your browser's session cookie. The login page ships that token as a<meta name="csrf-token">tag minted server-side (internal/web/controller/dist.go:123-128), and the UI even retries once with a freshly fetched token when it sees a 403 (frontend/src/api/http-init.ts:177-184). For this to still fail, the3x-uisession cookie has to not be coming back on the POST at all.The "Listen Domain" setting. If Settings → Panel Settings → Listen Domain (
webDomain) is non-empty, this middleware runs on every panel route (internal/web/web.go:183-185) and rejects anything whoseHostheader is not an exact, case-sensitive match:Something in front of the panel — Cloudflare (WAF, Bot Fight Mode, a Cache Rule), a Cloudflare Tunnel, or an nginx
denyrule — returning its own 403 before the request ever reaches the Go process. You left the reverse-proxy/CDN section of the form blank, so I cannot rule this out.Two things worth trying before you answer, since they are free: open the panel in a private/incognito window, and if that works, clear cookies for the panel's origin in your normal profile. A stale or undecodable
3x-uicookie leaves the session empty, which lands you in case 1. (This is the shape #5931 took — that reporter's log showedsecurecookie: error ... gob: name not registered for interface: "github.com/mhsanaei/3x-ui/v2/database/model.User", a leftover v2 cookie. I have not confirmed that mechanism in the source, so treat it as a hypothesis, not a diagnosis.)What I need to take this further
x-ui -von the server — the quoted error string is only produced by v3.4.2 and older, so this decides whether we are even looking at v3.7.0 code.GET /<basePath>/csrf-token, orPOST /<basePath>/login? Is the response body empty, or an HTML block page? Does it carry acf-rayorserver: cloudflareheader? Please paste the headers as text — I cannot open screenshots.https://, no trailing/, same case)?journalctl -u x-ui -e --no-pager -n 200. Every request that reaches the login handler logs a line, success or failure (internal/web/controller/index.go:100,:102,:116,:129) — so silence there is itself the answer: it proves the request was blocked earlier. Also grep it forsecurecookie.I retitled the issue for searchability — it was
[Bug]:with an empty summary. It still states your problem, not a conclusion.Verdict: Insufficient information
Severity: N/A — cannot be rated until the 403's origin is known
Confidence: High (that the report as filed cannot be evaluated; the 403 source mapping below is confirmed at the cited lines)
Root cause: Not established. Three mutually exclusive candidates, all confirmed present in v3.7.0: (a)
CSRFMiddlewareatinternal/web/middleware/security.go:51-54, applied toPOST /loginatinternal/web/controller/index.go:46, triggered when the3x-uisession cookie carries no CSRF token; (b)DomainValidatorMiddlewareatinternal/web/middleware/domainValidator.go:24-27, triggered on anyHostmismatch whenwebDomainis set (internal/web/web.go:183-185); (c) an upstream proxy/CDN 403 that never reaches the Go process. Credentials are excluded — a bad login is HTTP 200 (internal/web/controller/index.go:91,:111).Already fixed: Not applicable — no defect identified yet. All three 403 paths above are present on the default branch (
f727d04f, v3.7.0).Duplicate of: Related: #5931 (same symptom, closed as not-planned for lack of information; root cause never confirmed). Related: #4547 (persistent 403 that private-browsing mode cleared; also never root-caused).
Evidence:
frontend/src/api/http-init.ts:21—super(`Request failed with status ${status}`): v3.5.0+ emits no "code" in that string; repo-wide grep forRequest failed with statusmatches only this line and its test.frontend/package.jsonat tag v3.4.2, line 30 —"axios": "^1.18.1"; removed bybc309ed9, whose earliest containing tag is v3.5.0 (git tag --contains bc309ed9→ dev-latest, v3.5.0, v3.6.0, v3.7.0).internal/web/controller/index.go:46—g.POST("/login", middleware.CSRFMiddleware(), a.login).internal/web/middleware/security.go:51-54andinternal/web/session/csrf.go:33-47— the CSRF 403.internal/web/middleware/domainValidator.go:24-27andinternal/web/web.go:183-185— the Listen Domain 403.internal/web/controller/dist.go:123-128— the server-minted<meta name="csrf-token">onlogin.html.frontend/src/api/http-init.ts:177-184— the single 403-retry with a refreshed token.internal/web/translation/en-US.json:1206—"panelListeningDomain": "Listen Domain".Not determined: Which of the three 403 sources applies, and whether the running panel is really v3.7.0. The single check that settles the first: the DevTools Network entry for the failing request (item 3) — a
cf-ray/server: cloudflareheader points at the CDN, an empty-bodied 403 onPOST /<basePath>/loginpoints at CSRF, and a 403 on the page load itself points at Listen Domain.x-ui -v(item 1) settles the second.This reply was generated automatically; a maintainer may follow up.
@Mw-HbCK commented on GitHub (Sep 7, 2026):
I had the same
403 Forbiddenissue when trying to log in through the API with Pythonrequests.After checking the browser login flow, I found that sending a POST request directly to
/loginwas not enough.The working flow for me was:
GETrequest to the panel login page (/<base-path>/).3x-uisession cookie usingrequests.Session().application/x-www-form-urlencodedinstead of JSON.Example:
After adding the CSRF token and using the same session, the login succeeded with HTTP 200:
So if you are getting
403, try fetching the login page first and include the CSRF token in the login request.