Quick reference guide for diagnosing and fixing common issues.
# 1. Check all validation at once
python3 validate_project.py
# 2. Test Gemini API specifically
python3 test_gemini_api.py
# 3. Check running services health
python3 check_system_health.py
# 4. Check Docker services
docker compose ps
# 5. Check article count in database
curl http://localhost:8000/api/search/articles | jq '.pagination.total'# Step 1: Are there any articles?
curl http://localhost:8000/api/search/articles | jq '.pagination.total'If result is 0: No articles in database → See "No Articles" section below
If result is > 0: Articles exist but don't match search → Try different search terms
Check:
cat .env | grep GEMINI_API_KEY
# Should NOT show: your_gemini_api_key_hereTest:
python3 test_gemini_api.pyFix:
# 1. Get API key from https://makersuite.google.com/app/apikey
# 2. Edit .env
nano .env
# 3. Update line:
GEMINI_API_KEY=AIzaSyD9X8kFq2...your-actual-key...
# 4. Restart services
docker compose restart backend celery_workerCheck:
docker compose psFix:
# Start all services
docker compose up -d
# Wait for services to be healthy
sleep 30
# Verify
python3 check_system_health.pyCheck:
docker compose logs celery_worker | tail -50Look for:
- ✅ "celery@... ready."
- ✅ "connected to redis://..."
- ❌ Errors or exceptions
Fix:
# Restart Celery worker
docker compose restart celery_worker
# Watch logs
docker compose logs -f celery_workerCheck:
curl http://localhost:8000/api/keywords/ | jq '.pagination.total'Fix:
# Create and approve a keyword via API
curl -X POST http://localhost:8000/api/suggestions \
-H "Content-Type: application/json" \
-d '{"keyword_en": "Thailand", "category": "general"}'
# Approve it (replace ID with actual ID)
curl -X POST http://localhost:8000/api/admin/suggestions/1/approve \
-u admin:your_admin_password
# Monitor processing
docker compose logs -f celery_workerError: "port is already allocated"
Check what's using the port:
# PostgreSQL (5432)
sudo lsof -i :5432
# Redis (6379)
sudo lsof -i :6379
# Backend (8000)
sudo lsof -i :8000
# Frontend (3000)
sudo lsof -i :3000Fix:
# Option 1: Stop conflicting service
sudo systemctl stop postgresql
sudo systemctl stop redis-server
# Option 2: Change ports in docker-compose.yml
# Edit docker-compose.yml and change port mappingsCheck logs:
# View all logs
docker compose logs
# View specific service
docker compose logs postgres
docker compose logs backend
docker compose logs celery_workerCommon errors and fixes:
| Error | Service | Fix |
|---|---|---|
| "pg_isready: connection refused" | postgres | docker compose restart postgres |
| "ECONNREFUSED" to postgres | backend | Wait for postgres to be fully ready |
| "ModuleNotFoundError" | backend | Rebuild: docker compose up -d --build backend |
| "Cannot connect to Redis" | celery_worker | docker compose restart redis |
| "ImportError" | any Python | Check requirements.txt installed |
# Is backend running?
docker compose ps backend
# Check backend logs
docker compose logs backend | tail -50
# Test health endpoint
curl http://localhost:8000/healthFix:
# Rebuild backend container
docker compose up -d --build backend
# Or install manually (if not using Docker)
cd backend
pip install -r requirements.txtDatabase connection failed
Fix:
# Check DATABASE_URL in .env
cat .env | grep DATABASE_URL
# Should be: postgresql://newsadmin:PASSWORD@postgres:5432/news_intelligence
# Restart database
docker compose restart postgres
# Wait for it to be ready
docker compose exec postgres pg_isready -U newsadminBackend not listening
Fix:
# Check if port is bound
netstat -tuln | grep 8000
# Restart backend
docker compose restart backend
# Check logs for startup errors
docker compose logs backendCheck:
# Is PostgreSQL running?
docker compose ps postgres
# Can we connect?
docker compose exec postgres psql -U newsadmin -d news_intelligence -c "SELECT version();"Fix:
# Restart PostgreSQL
docker compose restart postgres
# Check logs
docker compose logs postgres
# Verify data persists
docker volume ls | grep postgres_dataCheck:
# Count tables
docker compose exec postgres psql -U newsadmin -d news_intelligence -c "\dt"
# Count articles
docker compose exec postgres psql -U newsadmin -d news_intelligence -c "SELECT COUNT(*) FROM articles;"Fix:
# Re-run initialization
docker compose exec postgres psql -U newsadmin -d news_intelligence -f /docker-entrypoint-initdb.d/init_db.sql
# Or recreate database
docker compose down
docker volume rm eu-intelligence-hub_postgres_data
docker compose up -dCheck:
docker compose exec postgres psql -U newsadmin -d news_intelligence -c "SELECT * FROM pg_extension WHERE extname = 'vector';"Fix:
# Install pgvector
docker compose exec postgres psql -U newsadmin -d news_intelligence -c "CREATE EXTENSION IF NOT EXISTS vector;"# Check worker
docker compose logs celery_worker | tail -50
# Check beat scheduler
docker compose logs celery_beat | tail -50
# Check Redis (broker)
docker compose exec redis redis-cli ping
# Should return: PONG# Check if tasks are queued
docker compose exec redis redis-cli LLEN celery
# View queued tasks
docker compose exec redis redis-cli LRANGE celery 0 -1# Trigger news scraping manually
docker compose exec backend python -c "
from app.tasks.scraping import scrape_news
result = scrape_news.delay()
print(f'Task ID: {result.id}')
"
# Watch worker process it
docker compose logs -f celery_worker# Flush all tasks
docker compose exec redis redis-cli FLUSHALL
# Restart workers
docker compose restart celery_worker celery_beatCheck:
# Is frontend running?
docker compose ps frontend
# Check logs
docker compose logs frontend | tail -50
# Test connection
curl http://localhost:3000Fix:
# Restart frontend
docker compose restart frontend
# Rebuild (if React errors)
docker compose up -d --build frontendError: "Network request failed" or CORS error
Check:
# Is REACT_APP_API_URL correct?
docker compose exec frontend printenv REACT_APP_API_URL
# Should be: http://localhost:8000Fix:
# Update .env
echo "REACT_APP_API_URL=http://localhost:8000" >> .env
# Rebuild frontend
docker compose up -d --build frontendSymptoms:
- test_gemini_api.py fails
- Scraper logs show authentication errors
Fix:
# 1. Verify key format (should start with AIza)
cat .env | grep GEMINI_API_KEY
# 2. Get new key
# Visit: https://makersuite.google.com/app/apikey
# 3. Update .env
nano .env
# 4. Restart services
docker compose restart backend celery_workerError: "Resource has been exhausted (e.g. check quota)"
Check usage:
- Visit: https://makersuite.google.com/app/apikey
- View quota limits
Fix:
# Option 1: Wait (free tier resets)
# - 60 requests/minute limit
# - 1,500 requests/day limit
# Option 2: Reduce scraping frequency
# Edit .env:
SCRAPING_INTERVAL_HOURS=2 # Change from 1 to 2
# Restart
docker compose restart celery_beat# All services
docker compose logs
# Specific service
docker compose logs backend
docker compose logs celery_worker
docker compose logs postgres
# Follow logs (live)
docker compose logs -f backend
# Last N lines
docker compose logs --tail=100 backend
# With timestamps
docker compose logs --timestamps backend# Connect to database
docker compose exec postgres psql -U newsadmin -d news_intelligence
# Quick queries:
# Count articles
SELECT COUNT(*) FROM articles;
# Count keywords
SELECT COUNT(*) FROM keywords;
# View recent articles
SELECT id, title, source, published_date FROM articles ORDER BY published_date DESC LIMIT 5;
# Check article-keyword associations
SELECT COUNT(*) FROM keyword_articles;
# Exit: \q# Connect to Redis
docker compose exec redis redis-cli
# Check connection
PING
# View Celery queue length
LLEN celery
# List all keys
KEYS *
# Exit: exit# Restart specific service
docker compose restart backend
# Restart multiple
docker compose restart backend celery_worker
# Restart all
docker compose restart
# Stop and start (full reset)
docker compose down
docker compose up -d# Check container resource usage
docker stats
# Check disk space
docker system df
# Clean up unused resources
docker system pruneIf everything is broken and you want to start fresh:
# ⚠️ WARNING: This deletes all data!
# 1. Stop all services
docker compose down
# 2. Remove volumes (deletes database)
docker volume rm eu-intelligence-hub_postgres_data
docker volume rm eu-intelligence-hub_redis_data
# 3. Clean Docker system
docker system prune -a
# 4. Rebuild and start
docker compose up -d --build
# 5. Wait for services
sleep 60
# 6. Run validation
python3 check_system_health.pyBefore reporting an issue, verify:
- .env file exists and has real Gemini API key
- Docker is installed and running
- All services are up:
docker compose ps - Backend health check passes:
curl http://localhost:8000/health - Database is accessible:
docker compose exec postgres pg_isready - Redis is accessible:
docker compose exec redis redis-cli ping - Celery worker is running:
docker compose logs celery_worker | grep ready - No port conflicts:
netstat -tuln | grep -E '(3000|5432|6379|8000)' - Validation script passes:
python3 validate_project.py
If you're still stuck:
-
Run full diagnostic:
python3 validate_project.py > diagnostic.txt python3 check_system_health.py >> diagnostic.txt docker compose logs > docker_logs.txt
-
Check documentation:
- README.md - Project overview
- INSTALLATION.md - Setup guide
- DATA_FLOW_EXPLAINED.md - How data flows
- PROJECT_VALIDATION_REPORT.md - Detailed validation
-
Common issues solved:
- No results → Check DATA_FLOW_EXPLAINED.md
- Services won't start → Check INSTALLATION.md
- API errors → Check PROJECT_VALIDATION_REPORT.md
INFO: Application startup complete
INFO: Uvicorn running on http://0.0.0.0:8000
Database connection pool created successfully
[2025-11-14 10:00:00] celery@... ready.
Connected to redis://redis:6379/0
Scheduler: Sending due task scrape_news
Beat: Scheduler running...
WARNING: GEMINI_API_KEY not configured ← Fix API key
WARNING: No articles scraped ← API key issue
OperationalError: could not connect ← Database down
ConnectionError: Redis ← Redis down
ModuleNotFoundError ← Missing dependencies
ImportError ← Package installation failed
sqlalchemy.exc.OperationalError ← Database error
google.api_core.exceptions.InvalidArgument ← API key invalid
Last Updated: 2025-11-14 Version: 1.0