2 months ago
Problem:
I deploy a Python Telegram bot on Railway from GitHub. It worked earlier, then builds started failing with secret TOKEN not found. After changing variables and code, a different bot requiring subscription to A_ToolsX responds instead of mine. I created a new bot and new project, but it still fails. I need help with correct TOKEN setup and a clean deployment.
Resources:
Old project: precious-generosity, production, service my-courier-bot, repo nekitologin-glitch/my-courier-bot.
Failing deployment: 2026-10-04 ~21:31 MSK.
Last success: 2026-10-04 ~18:49 MSK.
New project/repo: [courier-bot-v2]
New service/deployment: [URL/ID]
Error:
text
install mise packages: python
secret TOKEN not found
Attempts:
Removed TOKEN variable.
Hardcoded token in code — same error.
Re-added TOKEN without trailing space, value from BotFather. After redeploy, bot came online but required subscription to A_ToolsX, not in my code.
Deleted old main.py, uploaded clean code — no change.
Created new bot and repo, but still not working.
Please check service configuration, variables, and build logs: why TOKEN is not found and why the deployed bot uses a token/channel not present in my code. Do not delete resources without my consent; I need diagnosis.
Prepared with Railway's support template (v1).
1 Reply
2 months ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 2 months ago
a month ago
Two checks can help separate the build failure from the unexpected replies without deleting either project.
- The failing step is before your Python bot starts.
Railpack makes declared build secrets available to steps by default through BuildKit secret mounts. Seeing TOKEN fail at “install mise packages: python” does not by itself prove that your Python code reads TOKEN during installation, or that a dangling variable reference is the cause. Hardcoding TOKEN in main.py cannot supply that missing build secret.
In the exact service/environment used by the failing deployment, apply the staged variable changes and inspect the newly created deployment. Shared variables are supported, but must be referenced by the service. If you duplicated a service or environment and TOKEN was sealed, Railway explicitly says sealed values are not copied; re-enter it in the destination service. If a fresh build still reports the missing secret with the correct variable present, Railway needs the deployment ID and redacted build step to inspect secret provisioning.
References:
https://railpack.com/architecture/secrets
https://docs.railway.com/variables
- Correct bot identity can still coexist with the wrong responder.
After checking getMe, if it returns your intended bot, also check Telegram's read-only getWebhookInfo privately. An old webhook can still send updates to an older or unexpected server even after main.py is replaced. A nonempty webhook URL means updates are being delivered there; Telegram does not allow getUpdates polling while an outgoing webhook is configured. Compare that target with the deployment you intend to run before changing it. Keep the full webhook URL private because its path may contain a secret.
If getMe identifies a different bot, correct the token source. If it identifies the right bot but the responder is unexpected, inspect the webhook target and any other process using that token. If the token was exposed in a public commit, revoke it through BotFather and replace it before relying on the new deployment. Creating another project alone will not invalidate an exposed token.
References:
https://core.telegram.org/bots/api#getme
https://core.telegram.org/bots/api#getwebhookinfo
https://core.telegram.org/bots/features#generating-an-authentication-token
This is AI-assisted analysis of the public report and linked documentation; I have not accessed your private service, token, or logs. The underlying cause still needs confirmation from those checks.