Troubleshooting¶
This guide helps diagnose and resolve common issues with the RAG Chatbot.
Quick Diagnostics¶
System Health Check¶
Run these commands to verify all components:
# Check web server
curl -I http://localhost/chatbot/public/
# Check database connection
psql -h localhost -U raguser -d ragdb -c "SELECT 1;"
# Check Docling service
curl http://localhost:8001/health
# Check PHP-FPM
sudo systemctl status php-fpm
View Recent Errors¶
# PHP errors
sudo tail -50 /var/log/php-fpm/www-error.log
# Apache errors
sudo tail -50 /var/log/httpd/chatbot-error.log
# Application logs
ls -la /var/www/chatbot/logs/
Chat Issues¶
"I don't have enough information to answer that question"¶
Cause: No relevant documents match the query.
Solutions:
- Verify documents are uploaded:
- Test the search directly:
- Lower the search threshold:
- Check if embeddings exist:
Slow Responses¶
Possible causes:
| Cause | Check | Solution |
|---|---|---|
| Large knowledge base | Check chunk count | Optimize indexes |
| Network latency to LLM | Test API directly | Use closer region |
| Database performance | Check query times | Run VACUUM ANALYZE |
| Memory pressure | Check system memory | Increase RAM |
Database optimization:
-- Analyze tables
VACUUM ANALYZE documents;
VACUUM ANALYZE chunks;
VACUUM ANALYZE embeddings;
-- Check index usage
SELECT indexrelname, idx_scan, idx_tup_read
FROM pg_stat_user_indexes
WHERE schemaname = 'public';
Rate Limit Errors (429)¶
Cause: Too many requests from same session/IP.
Solutions:
- Wait for the window to reset (check
Retry-Afterheader) - Increase limits in code if legitimate traffic
- Use different session IDs for different users
Upload Issues¶
"File type not allowed"¶
Cause: Extension not in whitelist.
Solution: Check supported formats in Uploading Documents.
"Document parsing service unavailable"¶
Cause: Docling service is not running or unreachable.
Check:
# Is the service running?
docker ps | grep docling
# Can you reach it?
curl http://localhost:8001/health
# Check logs
docker logs docling-service
Solutions:
- Start the service:
docker compose up -d - Check firewall allows port 8001
- Verify
DOCLING_SERVICE_URLin.env
Upload Timeout¶
Cause: Large file or slow processing.
Solutions:
- Increase timeout in
.env:
- Increase PHP timeout:
- Increase web server timeout (Apache):
"No transcript available" (Media Import)¶
Cause: Video has no subtitles and transcription failed.
Solutions:
- Check if the video has subtitles on the platform
- Ensure Docling has transcription models loaded
- Try different subtitle languages
Database Issues¶
Connection Refused¶
Symptoms: "could not connect to server"
Check:
# Is PostgreSQL running?
sudo systemctl status postgresql-16
# Is it listening?
ss -tlnp | grep 5432
# Check pg_hba.conf
sudo cat /var/lib/pgsql/16/data/pg_hba.conf
Solutions:
- Start PostgreSQL:
sudo systemctl start postgresql-16 - Update pg_hba.conf to allow connections
- Check DB_HOST in
.envmatches actual host
pgvector Extension Missing¶
Symptoms: "type vector does not exist"
Solution:
# Reinstall pgvector
cd /tmp/pgvector
make clean
make
sudo make install
# Enable in database
sudo -u postgres psql -d ragdb -c "CREATE EXTENSION vector;"
Slow Queries¶
Diagnose:
-- Find slow queries
SELECT query, calls, mean_exec_time
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;
-- Check if HNSW index is used
EXPLAIN ANALYZE
SELECT * FROM embeddings
ORDER BY embedding <=> '[0.1,0.2,...]'::vector
LIMIT 5;
Solutions:
-- Rebuild indexes
REINDEX TABLE embeddings;
-- Update statistics
ANALYZE embeddings;
-- Increase work_mem for complex queries
SET work_mem = '256MB';
LLM Provider Issues¶
OpenAI API Errors¶
"Invalid API key":
- Verify key in
.env - Check key hasn't expired
- Ensure no extra whitespace
"Rate limit exceeded":
- Check your OpenAI usage dashboard
- Upgrade your plan if needed
- Implement request queuing
"Model not found":
- Verify model name in
.env - Check you have access to the model
- Use a valid model:
gpt-4,gpt-4-turbo,gpt-3.5-turbo
Claude API Errors¶
"Authentication failed":
- Verify ANTHROPIC_API_KEY
- Check key format starts with
sk-ant-
Test API directly:
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":100,"messages":[{"role":"user","content":"Hello"}]}'
Docling Service Issues¶
Container Won't Start¶
Check logs:
Common issues:
| Error | Solution |
|---|---|
| Port in use | Change port in docker-compose.yml |
| CUDA error | Install nvidia-container-toolkit |
| Out of memory | Reduce MAX_CONCURRENT_JOBS |
GPU Not Detected¶
Verify GPU access:
# Check NVIDIA driver
nvidia-smi
# Test Docker GPU access
docker run --rm --gpus all nvidia/cuda:11.8-base nvidia-smi
Solutions:
- Install nvidia-container-toolkit
- Restart Docker:
sudo systemctl restart docker - Set
DOCLING_DEVICE_MODE=cudaexplicitly
OCR Not Working¶
Check:
# Verify OCR is enabled
grep DOCLING_ENABLE_OCR .env
# Check OCR language
grep DOCLING_OCR_LANGUAGE .env
Solutions:
- Enable OCR:
DOCLING_ENABLE_OCR=true - Set correct language:
DOCLING_OCR_LANGUAGE=en - Ensure image quality is sufficient
Chat Widget Issues¶
Widget Not Loading¶
Check browser console for errors (F12 → Console)
Common issues:
| Error | Solution |
|---|---|
| 404 on script | Verify script URL path |
| CORS error | Configure CORS headers |
| JavaScript error | Check for conflicts with other scripts |
Widget Styling Broken¶
Solutions:
- Check for CSS conflicts with your site
- Ensure widget CSS isn't being overridden
- Try loading widget in an iframe
Session Not Persisting¶
Cause: localStorage blocked or cleared.
Solutions:
- Check if localStorage is available
- Verify cookies aren't being blocked
- Check for browser privacy settings
Performance Issues¶
High Memory Usage¶
Check:
# System memory
free -h
# PHP-FPM memory
ps aux | grep php-fpm
# PostgreSQL memory
ps aux | grep postgres
Solutions:
- Reduce PHP-FPM workers
- Lower PostgreSQL
shared_buffers - Limit Docling concurrent jobs
High CPU Usage¶
Identify the cause:
Common culprits:
| Process | Solution |
|---|---|
| php-fpm | Reduce workers, optimize queries |
| postgres | Run VACUUM, optimize indexes |
| docling | Reduce concurrent jobs |
Getting Help¶
Information to Gather¶
When seeking help, provide:
- Error messages - Exact text from logs
- Steps to reproduce - What you did
- Environment - OS, PHP version, PostgreSQL version
- Configuration - Relevant
.envsettings (redact secrets!)
Log Locations¶
| Component | Log Path |
|---|---|
| PHP | /var/log/php-fpm/www-error.log |
| Apache | /var/log/httpd/chatbot-error.log |
| Nginx | /var/log/nginx/error.log |
| PostgreSQL | /var/lib/pgsql/16/data/log/ |
| Docling | docker compose logs docling |
| Application | /var/www/chatbot/logs/ |
Debug Mode¶
Enable verbose logging temporarily:
Access debug logs at /api-debug/logs (requires authentication).
Warning
Disable debug logging in production after troubleshooting.