19 days ago
I'm experiencing an issue with volume mounting in my Telegram Bot application. Here's the setup:
Configuration:
Service: Node.js application with Telegram Bot API local mode
Volume: 45GB mounted at
/app/shared_data
Environment:
RAILWAY_VOLUME_MOUNT_PATH=/app/shared_data
Problem: When users send files to the bot, Telegram Bot API is supposed to save them to the mounted volume at /app/shared_data
. However:
Volume usage remains flat at ~0GB despite the memory increase
Volume graphs show no activity while memory graphs show clear spikes
Attachments
2 Replies
19 days ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
19 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 19 days ago
17 days ago
Why your volume stays at \~0 GB
Two common gotchas with Telegram’s Local Bot API:
1. Your bot is still calling https://api.telegram.org
(the default), not your local server → no files touch your volume. You must point your bot library to the local base URL (e.g. http://localhost:8081
).
2. The Bot API only saves files after you ask for them (e.g. via getFile
or by downloading the returned path). Just receiving updates with file_id
does not write to disk.
----
Fix (do all 4):
1. Verify you’re talking to local API
bash:
If this fails or your app still hits api.telegram.org
, you’re not using local mode.
-
2. Point your library at the local base URL
Telegraf:
js
const bot = new Telegraf(token, { telegram: { apiRoot: process.env.TELEGRAM_BOT_API_URL || 'http://localhost:8081' } });
grammY:
ts
const bot = new Bot(token, { client: { apiRoot: process.env.TELEGRAM_BOT_API_URL || 'http://localhost:8081' } });
node-telegram-bot-api:
js
const bot = new TelegramBot(token, { polling: true, baseApiUrl: process.env.TELEGRAM_BOT_API_URL || 'http://localhost:8081' });
-
3. Actually download the file (this triggers disk writes)
js
// example (generic)
const f = await bot.api.getFile(fileId); // or library equivalent
const url = new URL(`/file/bot${token}/${f.file_path}`, process.env.TELEGRAM_BOT_API_URL || 'http://localhost:8081');
// stream url ->
${process.env.RAILWAY_VOLUME_MOUNT_PATH}/${path.basename(f.file_path)}
(Local server downloads to its --dir
only when you call getFile
/download.)
-
4. Write to the mounted volume path
Use Railway’s injected env:
RAILWAY_VOLUME_MOUNT_PATH
(don’t hardcode).Quick check at startup:
bash
echo "VOL=$RAILWAY_VOLUME_MOUNT_PATH"; touch "$RAILWAY_VOLUME_MOUNT_PATH/probe"
----
Run flags recap (for your Bot API process)
Start it with --local --dir "$RAILWAY_VOLUME_MOUNT_PATH" --temp-dir /app/temp
and then point your bot to http://localhost:8081
as above.
---
Sanity checks
ls -lah "$RAILWAY_VOLUME_MOUNT_PATH"
while sending a test file.Watch Railway’s Volume graph; it should now show writes. (Env exposes the mount path; verify with
echo
.)
Once the bot uses the local base URL and you call getFile
/download, files land under your volume and the usage graph will climb.