mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5851] [Bug]: Telegram Bot Returns Incorrect Subscription Link Using Host Name Instead of Domain #4064
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#4064
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 @parsa-fathi on GitHub (Jul 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5851
Describe the bug
Description:
When requesting a client's subscription link through the Telegram bot in 3x-ui, the generated URL is always incorrect.
Instead of using the configured domain name, the bot uses the server's host name as the domain part of the subscription URL. As a result, the generated subscription link becomes invalid or inaccessible for clients.
Steps to Reproduce:
Expected Behavior:
The Telegram bot should generate the subscription link using the configured domain name, matching the link shown in the panel.
Actual Behavior:
The Telegram bot generates the subscription link using the server host name instead of the configured domain name.
Impact:
Users receive incorrect subscription links from the Telegram bot and may be unable to import or update their configurations until the link is manually corrected.
How to reproduce the problem
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
Ubuntu26
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?
None
Before submitting
@github-actions[bot] commented on GitHub (Jul 7, 2026):
Confirmed as a bug in the Telegram bot's link-building logic, not in the panel itself.
Root cause:
buildSubscriptionURLsininternal/web/service/tgbot/tgbot_client.go(lines 150-177) resolves the subscription host in this order:subDomainsetting ("Listen Domain" under Panel Settings -> Subscription Settings)webDomainsetting ("Listen Domain" under Panel Settings -> Panel Settings)os.Hostname(), cached at bot startup bySetHostname()intgbot.go)"localhost"Both
subDomainandwebDomaindefault to an empty string (internal/web/service/setting.go, lines 38 and 88) and their UI description explicitly says to leave them blank in normal installs ("leave blank to listen on all domains and IPs"). When you reach the panel through your domain without filling in either field, the subscription link shown in the panel/web UI is still correct because it is built from the incoming HTTP request'sHostheader (SettingService.BuildSubURIBase,internal/web/service/setting.golines 1243-1260), not from a stored setting. The Telegram bot has no HTTP request to read a host from, so with both domain fields blank it falls through to the OS hostname, which is what you are seeing.Workaround: in Panel Settings -> Subscription Settings, set either:
Listen Domain(subDomain) to your domain, orReverse Proxy URI(subURI) to the full base URL, e.g.https://your-domain.com/sub/buildSubscriptionURLscheckssubURIfirst and uses it verbatim when set, otherwise it usessubDomainbefore ever falling back to the hostname, so either setting will make the bot's link match the one shown in the panel.This reply was generated automatically; a maintainer may follow up.
@Morteza820 commented on GitHub (Jul 8, 2026):
Dear parsa, change the host name to your sub link in terminal..
it will be solved.
BR,