Troubleshooting
This guide covers common issues, diagnostic steps, and solutions for Terragnos Core deployments.
Common Issues
API Won't Start
Symptoms:
- API container exits immediately
- Health checks fail
- No response from API endpoints
Diagnostic steps:
-
Check container logs:
docker compose logs api -
Verify environment variables:
docker compose config -
Check database connectivity:
docker compose exec api env | grep DATABASE_URL
Common causes:
- Missing or invalid
DATABASE_URL - Database not accessible
- Invalid
AUTH_JWT_SECRETformat - Port already in use
Database Connection Errors
Symptoms:
ECONNREFUSEDerrors in logs- API returns 500 errors
- Health check shows database as unhealthy
Diagnostic steps:
-
Verify database is running:
docker compose ps db -
Test database connection:
docker compose exec db psql -U terragnos -d terragnos -c "SELECT 1;" -
Check database logs:
docker compose logs db
Common causes:
- Database container not started
- Incorrect
DATABASE_URL - Database password mismatch
- Network connectivity issues
License Errors
Symptoms:
403 License limit exceededresponses- License-related errors in logs
- Features not available
Diagnostic steps:
-
Check license status:
curl -H "Authorization: Bearer <token>" \
http://localhost:3000/v1/license -
Verify license environment variables:
docker compose exec api env | grep LICENSE -
Check license expiration:
{
"status": "expired",
"expiresAt": "2024-01-01T00:00:00Z"
}
Common causes:
- License expired
- License limit reached
- Invalid license key
- Missing
LICENSE_PUBLIC_KEY
Authentication Failures
Symptoms:
401 Unauthorizedresponses- Cannot access API endpoints
- Token validation errors
Diagnostic steps:
-
Verify JWT token format:
# Decode JWT (without verification)
echo "<token>" | cut -d. -f2 | base64 -d -
Check token expiration:
{
"exp": 1704153600 // Unix timestamp
} -
Verify
AUTH_JWT_SECRETmatches token issuer
Common causes:
- Expired token
- Invalid token signature
- Missing or incorrect
AUTH_JWT_SECRET - Token missing required claims (
tenant,sub)
Workflow Transition Failures
Symptoms:
403 Forbiddenon workflow transitions- Transitions blocked by guards
- Workflow state not updating
Diagnostic steps:
-
Check available transitions:
curl -H "Authorization: Bearer <token>" \
http://localhost:3000/v1/objects/{id}/workflow/explain-transitions -
Review guard requirements:
{
"availableTransitions": [
{
"targetState": "approved",
"guards": [
{
"type": "permission",
"requiredRole": "admin",
"evaluated": false,
"reason": "User does not have admin role"
}
]
}
]
}
Common causes:
- Insufficient permissions
- Guard conditions not met
- Object in invalid state
- Workflow version mismatch
Automation Rule Not Executing
Symptoms:
- Automation rules not triggering
- No execution logs
- Expected effects not happening
Diagnostic steps:
-
Check rule status:
curl -H "Authorization: Bearer <token>" \
http://localhost:3000/v1/automation/rules/{ruleId} -
View execution history:
curl -H "Authorization: Bearer <token>" \
http://localhost:3000/v1/automation/rules/{ruleId}/runs -
Check worker logs:
docker compose logs worker | grep automation
Common causes:
- Rule not activated
- Match conditions not met
- Worker service not running
- Rule in draft/sandbox state
Diagnostic Commands
Check Service Status
# All services
docker compose ps
# Specific service
docker compose ps api
View Logs
# All services
docker compose logs -f
# Specific service
docker compose logs -f api
# Last 100 lines
docker compose logs --tail=100 api
Test API Connectivity
# Health check
curl http://localhost:3000/v1/health/live
# With authentication
curl -H "Authorization: Bearer <token>" \
http://localhost:3000/v1/health/ready
Database Diagnostics
# Connect to database
docker compose exec db psql -U terragnos -d terragnos
# Check table sizes
SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS size
FROM pg_tables
WHERE schemaname = 'public'
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
# Check active connections
SELECT count(*) FROM pg_stat_activity;
License Diagnostics
# Check license status
curl -H "Authorization: Bearer <admin-token>" \
http://localhost:3000/v1/license
# Check license in database
docker compose exec db psql -U terragnos -d terragnos -c \
"SELECT * FROM system_licenses ORDER BY created_at DESC LIMIT 1;"
Performance Issues
Slow API Responses
Diagnostic steps:
-
Check database query performance:
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10; -
Check for missing indexes:
SELECT schemaname, tablename, attname, n_distinct
FROM pg_stats
WHERE schemaname = 'public'
AND n_distinct > 100; -
Monitor API metrics:
curl http://localhost:3000/metrics | grep http_request_duration
Solutions:
- Add database indexes
- Optimize queries
- Increase database resources
- Enable caching (Redis)
High Memory Usage
Diagnostic steps:
-
Check container memory:
docker stats -
Review log levels (reduce verbosity if needed)
-
Check for memory leaks in application logs
Solutions:
- Increase container memory limits
- Reduce log verbosity
- Restart services periodically
- Optimize query patterns
Getting Help
When reporting issues, include:
- Service logs – Relevant log entries
- Configuration – Environment variables (sanitized)
- Error messages – Exact error text
- Steps to reproduce – What actions led to the issue
- Version information – Container image tags
- Health check status – Results from
/v1/health/ready
Contact Terragnos support with this information for assistance.