Quick Diagnosis
Setup Issues
Database Connection Errors
Error: could not connect to server
Error: could not connect to server
Problem:
django.db.utils.OperationalError: could not connect to serverSolutions:- Verify PostgreSQL is running:
- Check database credentials in
.env:
- Create database if missing:
- Test connection:
Database does not exist
Database does not exist
Problem: Database not created during setupSolution:
Redis Connection Errors
Error: connecting to Redis
Error: connecting to Redis
Problem:
ConnectionError: Error connecting to RedisSolutions:- Verify Redis is running:
- Check Redis URL in
.env:
- Start Redis:
- Test connection:
Module Import Errors
ModuleNotFoundError
ModuleNotFoundError
Problem:
ModuleNotFoundError: No module named 'core'Solutions:- Ensure correct directory:
- Activate virtual environment:
- Install dependencies:
- Verify installation:
Runtime Issues
Rate Limit Exceeded
403 Forbidden with rate limit message
403 Forbidden with rate limit message
Problem: API returns 403 with rate limit errorSolutions:
- Wait for rate limit to reset (default: 1 hour)
-
Increase rate limit in
.env:
- Whitelist IP for testing (in
.env):
- Check current rate limit status:
- Clear rate limit (development only):
Slow API Responses
API responses are slow
API responses are slow
Solutions:
- Check Redis cache is working:
- Check response time headers:
- Enable query logging (temporarily in
settings.py):
- Review slow query logs:
- Warm cache:
Cache Not Working
Cache doesn't seem to be working
Cache doesn't seem to be working
Solutions:
- Verify Redis connection (see Redis section above)
-
Check cache configuration in
settings.py:
- Clear cache manually:
- Check cache keys:
- Test cache from Django shell:
Database Migration Errors
InconsistentMigrationHistory
InconsistentMigrationHistory
Problem:
django.db.migrations.exceptions.InconsistentMigrationHistorySolutions:- Check migration history:
- Fake migration (use with caution):
- Reset migrations (development only):
Migrations not applying
Migrations not applying
Solutions:
- Create migrations:
- Apply migrations:
- Check for conflicts:
Testing Issues
Tests Failing
Tests fail with import errors
Tests fail with import errors
Solutions:
- Check pytest.ini configuration:
- Run tests from project root:
- Clear test database:
- Verify test settings:
Coverage Not Working
Coverage report shows 0% or missing files
Coverage report shows 0% or missing files
Solutions:
- Install coverage tools:
- Run with coverage:
- Check configuration in
pyproject.toml:
Scraping Issues
Scraping Fails with Connection Errors
ConnectionError or timeout
ConnectionError or timeout
Problem:
requests.exceptions.ConnectionError or timeoutSolutions:- Check internet connection
- Verify target website is accessible:
-
Check proxy settings in
core/http.py -
Increase timeout in
.env:
HTML Parsing Errors
AttributeError or KeyError during parsing
AttributeError or KeyError during parsing
Solutions:
- Check if website structure changed
- Log raw HTML for debugging:
- Review HTML fixtures in tests
- Add defensive checks in parsers:
Duplicate Data Issues
Duplicate clubs or kits created
Duplicate clubs or kits created
Solutions:
- Check slug uniqueness constraints
- Use get_or_create() instead of create():
- Find duplicates:
API Issues
500 Internal Server Error
API returns 500 error
API returns 500 error
Solutions:
- Check Django logs:
- Enable DEBUG mode (temporarily in
.env):
- Check database connection
- Verify environment variables:
- Test endpoint directly:
API Documentation Not Loading
/api/docs returns 404 or error
/api/docs returns 404 or error
Solutions:
- Verify Django Ninja is installed:
- Check URL configuration in
fkapi/urls.py:
- Access correct URL:
Performance Issues
High Database Query Count
Too many queries per request
Too many queries per request
Solutions:
- Use select_related() for foreign keys:
- Use prefetch_related() for many-to-many:
- Check query count in response headers:
- Enable query logging (see Slow API Responses)
Memory Issues
High memory usage
High memory usage
Solutions:
- Use pagination for large datasets
- Process data in chunks:
- Clear cache periodically:
- Monitor with django-debug-toolbar (development)
Getting More Help
Check Logs
Review
fkapi/api.log and fkapi/logs/performance.logEnable Debug
Set
DJANGO_DEBUG=True for detailed error messagesDocumentation
Review other docs in
/docs directoryGitHub Issues
Search existing issues or create new one
Common Error Messages
django.core.exceptions.ImproperlyConfigured
Usually means missing or incorrect settings. Check:
- Environment variables in
.env - Database configuration
- Redis configuration
django.db.utils.IntegrityError
Database constraint violation. Check:
- Unique constraints
- Foreign key relationships
- Required fields
ninja.errors.ValidationError
API request validation failed. Check:
- Required parameters
- Parameter types
- Request body format
core.exceptions.ScrapingError
Scraping operation failed. Check:
- Network connectivity
- Target website availability
- HTML structure changes
Still having issues? Open an issue on GitHub with:
- Error message and full stack trace
- Steps to reproduce
- Environment details (OS, Python version, etc.)
- Relevant logs