[GH-ISSUE #5073] [Bug]: Telegram Bot doesnt work via panel proxy #3572

Closed
opened 2026-10-31 20:33:24 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Loginlag on GitHub (Jun 8, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5073

Describe the bug

Telegram bot is not routed through a socks5 proxy even though I specified it in the panel settings

I tried doing exactly the same thing on another server (3x-ui version 2.9.3), and everything worked as it should
Also I tried to replace telegram bot tokens but it didnt work.

  • tried sending a curl request using proxy to tg api, and it worked fine (docker exec -it 3x-ui curl -v -x socks5://login:password@127.0.0.1:1050 https://api.telegram.org)

How to reproduce the problem

  1. Create inbound mixed with address 127.0.0.1, port 1050, udp disabled, sniffing enabled.
  2. Set socks5 connection in the settings (example: socks5://login:password@127.0.0.1:1050)
  3. Check xray logs. There are logs showing that tcp:api.github.com:443 is being successfully proxied but there isnt tcp:api.telegram.org:443

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

3x-ui latest version (3.2.8)
3x-ui latest version (3.2.8)

3x-ui version 2.9.3
3x-ui version 2.9.3

3x-ui version

3.2.8

Xray-core version

26.6.1

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Debian 12

Which parts of the panel are affected?

Telegram bot

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).

Also a bit offtop: link on existing issues when filling out the form is broken

Originally created by @Loginlag on GitHub (Jun 8, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5073 ### Describe the bug Telegram bot is not routed through a socks5 proxy even though I specified it in the panel settings I tried doing exactly the same thing on another server (3x-ui version 2.9.3), and everything worked as it should Also I tried to replace telegram bot tokens but it didnt work. + tried sending a curl request using proxy to tg api, and it worked fine (docker exec -it 3x-ui curl -v -x socks5://login:password@127.0.0.1:1050 https://api.telegram.org) ### How to reproduce the problem 1. Create inbound mixed with address 127.0.0.1, port 1050, udp disabled, sniffing enabled. 2. Set socks5 connection in the settings (example: socks5://login:password@127.0.0.1:1050) 3. Check xray logs. There are logs showing that tcp:api.github.com:443 is being successfully proxied but there isnt tcp:api.telegram.org:443 ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots 3x-ui latest version (3.2.8) <img width="1867" height="100" alt="3x-ui latest version (3.2.8)" src="https://github.com/user-attachments/assets/7d3c705e-ffca-4d38-a312-d7f531aea313" /> 3x-ui version 2.9.3 <img width="1067" height="154" alt="3x-ui version 2.9.3" src="https://github.com/user-attachments/assets/bfae279b-c93b-4a30-ad9d-1d26529fb024" /> ### 3x-ui version 3.2.8 ### Xray-core version 26.6.1 ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Debian 12 ### Which parts of the panel are affected? Telegram bot ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs). Also a bit offtop: link on **existing issues** when filling out the form is broken
bsakaguchi 2026-10-31 20:33:24 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 8, 2026):

Thanks for the detailed report, including the Xray log comparison — that clue is actually what pinpoints the exact cause.

What's happening

Starting with v3.2.0, the dedicated Telegram Bot Proxy field was removed from the Telegram settings tab. As a replacement, the bot code (web/service/tgbot.go, Start()) now falls back to the Panel Network Proxy (panelProxy) field found under Settings → General, if no dedicated tgBotProxy value is stored. That fallback logic is correct in the code.

The bug is in how the "Restart Panel" button behaves:

  • "Restart Panel" sends SIGHUP, which calls StartPanelOnly() internally.
  • StartPanelOnly() is wired to start(restartXray=false, startTgBot=false) — it intentionally does not restart the Telegram bot.
  • The bot continues running with the HTTP client (and its proxy dialer) that was constructed at the original service startup.

This explains the symptom you observed: api.github.com goes through the proxy (GitHub version checks call NewProxiedHTTPClient on every request, so they always pick up the current panelProxy value), but the Telegram bot does not (its fasthttp client is built once at startup and cached for the lifetime of the process).

Workaround

After setting Panel Network Proxy (socks5://login:password@127.0.0.1:1050) in the settings and saving, perform a full container restart instead of using "Restart Panel":

docker restart 3x-ui

This causes the service to go through server.Start() → start(restartXray=true, startTgBot=true), which rebuilds the bot's HTTP client with the new proxy.

The "Restart Panel" button alone is not sufficient for proxy changes to reach the Telegram bot.

Root cause summary

Action Restarts Telegram bot?
"Restart Panel" button (SIGHUP) ❌ No — startTgBot=false
docker restart 3x-ui / systemctl restart x-ui ✅ Yes — full Start()

The correct long-term fix would be for the SIGHUP restart path to also stop and restart the bot when it is enabled (i.e., pass startTgBot=true in StartPanelOnly, or stop the bot in StopPanelOnly).

<!-- gh-comment-id:4646844112 --> @github-actions[bot] commented on GitHub (Jun 8, 2026): Thanks for the detailed report, including the Xray log comparison — that clue is actually what pinpoints the exact cause. ## What's happening Starting with v3.2.0, the dedicated **Telegram Bot Proxy** field was removed from the Telegram settings tab. As a replacement, the bot code (`web/service/tgbot.go`, `Start()`) now falls back to the **Panel Network Proxy** (`panelProxy`) field found under **Settings → General**, if no dedicated `tgBotProxy` value is stored. That fallback logic is correct in the code. The bug is in how the **"Restart Panel"** button behaves: - "Restart Panel" sends `SIGHUP`, which calls `StartPanelOnly()` internally. - `StartPanelOnly()` is wired to `start(restartXray=false, startTgBot=false)` — it intentionally **does not restart the Telegram bot**. - The bot continues running with the HTTP client (and its proxy dialer) that was constructed at the original service startup. This explains the symptom you observed: `api.github.com` goes through the proxy (GitHub version checks call `NewProxiedHTTPClient` on every request, so they always pick up the current `panelProxy` value), but the Telegram bot does not (its fasthttp client is built once at startup and cached for the lifetime of the process). ## Workaround After setting **Panel Network Proxy** (`socks5://login:password@127.0.0.1:1050`) in the settings and saving, perform a **full container restart** instead of using "Restart Panel": ```bash docker restart 3x-ui ``` This causes the service to go through `server.Start()` → `start(restartXray=true, startTgBot=true)`, which rebuilds the bot's HTTP client with the new proxy. The "Restart Panel" button alone is not sufficient for proxy changes to reach the Telegram bot. ## Root cause summary | Action | Restarts Telegram bot? | |--------|----------------------| | "Restart Panel" button (SIGHUP) | ❌ No — `startTgBot=false` | | `docker restart 3x-ui` / `systemctl restart x-ui` | ✅ Yes — full `Start()` | The correct long-term fix would be for the `SIGHUP` restart path to also stop and restart the bot when it is enabled (i.e., pass `startTgBot=true` in `StartPanelOnly`, or stop the bot in `StopPanelOnly`).
Author
Owner

@Serg-lab26 commented on GitHub (Jun 8, 2026):

In the old version of 3x-ui, the proxy settings for the tg bot in the SQL database used the table ID 20 key tgBotProxy, but in the new version, the settings are saved in ID 83 key panelProxy. After upgrading to the new version, 3x-ui continues to use ID 20.

<!-- gh-comment-id:4647110262 --> @Serg-lab26 commented on GitHub (Jun 8, 2026): In the old version of 3x-ui, the proxy settings for the tg bot in the SQL database used the table ID 20 key tgBotProxy, but in the new version, the settings are saved in ID 83 key panelProxy. After upgrading to the new version, 3x-ui continues to use ID 20.
Author
Owner

@Loginlag commented on GitHub (Jun 8, 2026):

all it really took was to do docker compose restart
its quite unobvious imho. I expected that simply restarting panel via the gui would be enough

<!-- gh-comment-id:4647484454 --> @Loginlag commented on GitHub (Jun 8, 2026): all it really took was to do `docker compose restart` its quite unobvious imho. I expected that simply restarting panel via the gui would be enough
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#3572
No description provided.