Troubleshooting
Common issues and solutions for Alita Robot.
Troubleshooting
This guide covers common issues you may encounter when running Alita Robot and how to resolve them.
Bot Won’t Start
Invalid Bot Token
Error:
Failed to create new bot: invalid token
Solution:
- Verify your bot token from @BotFather
- Ensure no extra spaces or newlines in the token
- Check that the token format is correct:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
:::caution
Do not wrap the token in quotes in your .env file. The quotes become part of the value and will cause authentication failure.
:::
# Correct format in .env
BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
# Wrong - has quotes
BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
Database Connection Failed
Error:
[Database][Connection] Failed after 5 attempts: connection refused
Solutions:
-
Check PostgreSQL is running:
# Linux sudo systemctl status postgresql # Docker docker compose ps postgres -
Verify connection string:
# Test connection directly psql "postgres://user:pass@localhost:5432/alita?sslmode=disable" -
Check network access:
# Is the port open? nc -zv localhost 5432 -
Docker Compose: Ensure PostgreSQL is healthy before Alita starts:
depends_on: postgres: condition: service_healthy
Redis Connection Failed
Error:
[Redis] Failed to connect: connection refused
Solutions:
-
Check Redis is running:
redis-cli ping # Should return: PONG -
Verify address and password:
REDIS_ADDRESS=localhost:6379 REDIS_PASSWORD=your_password # Leave empty if no password -
Docker: Ensure Redis is started before Alita
MESSAGE_DUMP Invalid
Error:
[Bot] Failed to send startup message to log group
:::tip The easiest way to get a channel ID is to forward any message from the channel to @userinfobot. :::
Solutions:
-
Format: Channel ID must start with
-100:MESSAGE_DUMP=-100123456789 -
Bot access: Add the bot as an admin to the channel
-
Get correct ID: Forward a message from the channel to @userinfobot
Webhook Issues
Not Receiving Updates
Symptoms:
- Bot starts successfully
- No messages are processed
- Health check returns
healthy
Solutions:
-
Check webhook status:
curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"Look for:
urlshould match yourWEBHOOK_DOMAINhas_custom_certificateif using self-signed certlast_error_messagefor any errors
-
Verify domain is accessible:
curl -I https://your-domain.com/health -
Check SSL certificate:
openssl s_client -connect your-domain.com:443 -servername your-domain.com
401 Unauthorized
Error in Telegram webhook info:
"last_error_message": "Unauthorized"
Solutions:
-
Check WEBHOOK_SECRET matches:
- The URL path must be
/webhook; the secret is not part of the URL - The
X-Telegram-Bot-Api-Secret-Tokenheader must match yourWEBHOOK_SECRET
- The URL path must be
-
Verify configuration:
USE_WEBHOOKS=true WEBHOOK_DOMAIN=https://your-domain.com WEBHOOK_SECRET=your-secret-here
Connection Timeout
Error:
"last_error_message": "Connection timed out"
Solutions:
- Verify port 8080 is accessible from the internet
- Check firewall rules:
# Allow port 8080 sudo ufw allow 8080/tcp - Check reverse proxy/tunnel is running
Database Issues
Migration Failed
Error:
[Database][AutoMigrate] Migration failed: column already exists
Solutions:
Each migration file and its schema_migrations record are applied in one
transaction. If a statement fails, the file is rolled back and remains pending.
- Read the full error and statement preview to identify the failing migration.
- Reconcile the existing schema, then restart with
AUTO_MIGRATE=trueso the pending file can run again. - Check migration status:
make psql-status - Add a new forward migration if an already-applied schema needs to change. Applied migration files are checksum-verified and must not be edited.
:::caution
Do not bypass a production failure with AUTO_MIGRATE_SILENT_FAIL=true or
manually insert a schema_migrations row. Either can run the bot against an
incomplete schema.
:::
Too Many Connections
Error:
pq: too many connections for role "alita"
Solutions:
-
Reduce connection pool size:
DB_MAX_OPEN_CONNS=50 DB_MAX_IDLE_CONNS=10 -
Increase PostgreSQL max connections:
# In postgresql.conf max_connections = 200 -
Use connection pooling (PgBouncer):
DATABASE_URL=postgres://user:pass@pgbouncer:6432/alita
Query Timeout
Error:
pq: canceling statement due to statement timeout
Solutions:
-
Check for slow queries:
SELECT pid, query, state, query_start FROM pg_stat_activity WHERE state != 'idle' ORDER BY query_start; -
Add indexes for slow queries
-
Increase timeout (not recommended for production)
Permission Errors
Bot Lacks Admin Rights
Error:
telegram: Bad Request: need administrator rights in the chat
Solutions:
- Promote the bot to admin in the group
- Grant specific permissions:
- Delete messages
- Ban users
- Pin messages
- Manage topics (for forum groups)
User Not Admin
Error:
You need to be an admin to use this command
This is expected behavior. Admin commands require the user to be a group admin.
Cannot Restrict Chat Owner
Error:
telegram: Bad Request: can't restrict chat owner
This is a Telegram limitation. The chat owner cannot be:
- Banned
- Muted
- Warned
Admin Commands Fail for Unfamiliar Users
Symptoms:
/promote @usernamefails even though the user exists- Commands work when replying but not when using usernames
Resolved in recent versions: Previously, admin commands required users to exist in the bot’s local database. The bot now queries Telegram’s API as a fallback when username lookup fails locally, allowing admin commands to work on any valid Telegram user.
If you’re running an older version, upgrade to get this fix.
Performance Issues
High Memory Usage
Symptoms:
- Memory exceeds
RESOURCE_MAX_MEMORY_MB - Bot becomes slow or unresponsive
Solutions:
-
Enable auto-remediation:
ENABLE_PERFORMANCE_MONITORING=true RESOURCE_MAX_MEMORY_MB=500 RESOURCE_GC_THRESHOLD_MB=400 -
Reduce update concurrency:
DISPATCHER_MAX_ROUTINES=100 -
Check for memory leaks:
DEBUG=true # Enable detailed logging
Slow Response Times
Symptoms:
- Commands take several seconds to execute
- Database queries are slow
Solutions:
-
Check database performance:
-- Find slow queries SELECT query, calls, mean_exec_time FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10; -
Tune connection pooling for your database limit:
DB_MAX_IDLE_CONNS=50 DB_MAX_OPEN_CONNS=200 -
Tune the always-enabled Telegram HTTP pool:
HTTP_MAX_IDLE_CONNS=100 HTTP_MAX_IDLE_CONNS_PER_HOST=50
High CPU Usage
Solutions:
-
Limit concurrent goroutines:
DISPATCHER_MAX_ROUTINES=100 RESOURCE_MAX_GOROUTINES=1000 -
Check for infinite loops in logs
-
Profile with pprof (development only)
Log Analysis
Enable Debug Logging
:::tip Enable debug logging when investigating issues, then disable it once the problem is resolved. Leaving debug mode on degrades performance. :::
DEBUG=true
Common Log Fields
| Field | Description |
|---|---|
update_id |
Telegram update identifier |
error_type |
Error type (e.g., *TelegramError) |
file |
Source file |
line |
Line number |
function |
Function name |
Finding Errors in Logs
# Docker
docker compose logs alita 2>&1 | grep -i error
# Systemd
journalctl -u alita-robot | grep -i error
# Last 100 errors
docker compose logs --tail=1000 alita 2>&1 | grep -i error | tail -100
Log Levels
| Level | When to Use |
|---|---|
| DEBUG | Verbose debugging (requires DEBUG=true) |
| INFO | Normal operations |
| WARN | Expected issues (e.g., user blocked bot) |
| ERROR | Unexpected failures |
| FATAL | Critical errors that stop the bot |
Docker-Specific Issues
Container Keeps Restarting
# Check exit code
docker compose ps
# View logs
docker compose logs alita
# Check for OOM kill
docker inspect alita-robot | grep -i oom
Health Check Failing
# Test health endpoint manually
docker compose exec alita /app/alita_robot --health
# Or from host
curl http://localhost:8080/health
Cannot Connect to Other Services
:::caution
Inside Docker Compose, services communicate by service name, not localhost. Use the Docker Compose service name (e.g., postgres, redis) as the hostname in connection strings.
:::
# Check network
docker network inspect alita_robot_default
# Verify service names match in DATABASE_URL and REDIS_ADDRESS
DATABASE_URL=postgresql://alita:alita@postgres:5432/alita # Use service name, not localhost
Internationalization (i18n) Issues
Empty Bot Responses
Symptoms:
- Bot sends empty messages
- Commands execute but no text is displayed
- Works in some languages but not others
Cause: Translation key mismatch between code and locale files.
Solutions:
-
Check translation key exists in all locale files:
# Search for a key in all locale files grep -r "misc_user_not_found" locales/ -
Verify key names match exactly:
- Code uses:
tr.GetString("misc_translate_need_text") - Locale file must have:
misc_translate_need_text: "..." - Common issue: Similar but different key names (e.g.,
misc_need_text_and_langvsmisc_translate_need_text)
- Code uses:
-
Add missing keys: If a key exists in one locale but not another, add it to all supported locales.
-
Check YAML syntax:
# Correct - double quotes for escape sequences misc_result: "Line 1\nLine 2" # Wrong - single quotes preserve \n literally misc_result: 'Line 1\nLine 2'
Translation Errors Logged
Error:
[i18n] Translation key not found: misc_example_key
Solution: Add the missing key to all locale files in locales/.
Getting Help
If you cannot resolve an issue:
- Check existing issues: GitHub Issues
- Enable debug logging and collect relevant logs
- Open a new issue with:
- Full error message
- Steps to reproduce
- Environment details (OS, Docker version, etc.)
- Relevant configuration (without secrets)