🔌 Connection Troubleshooting

Diagnose and resolve integration connectivity issues.


NATS Connection Issues

Symptoms

Diagnostic Steps

1
2
3
4
5
6
7
8
9
10
11
# 1. Check NATS container status
docker ps | grep nats

# 2. Test connectivity
nc -zv localhost 4222

# 3. Check NATS logs
docker logs sea-nats --tail 100

# 4. Verify JetStream enabled
nats server info | grep jetstream

Common Fixes

Issue Solution
Container not running docker-compose up -d nats
Port not exposed Check docker-compose.yml ports
JetStream disabled Add -js flag to NATS startup
TLS mismatch Verify certificate configuration

PostgreSQL Connection Issues

Symptoms

Diagnostic Steps

1
2
3
4
5
6
7
8
9
10
11
# 1. Check container status
docker ps | grep postgres

# 2. Test connectivity
pg_isready -h localhost -p 5432

# 3. Check connection count
psql $DATABASE_URL -c "SELECT count(*) FROM pg_stat_activity;"

# 4. View slow queries
psql $DATABASE_URL -c "SELECT query FROM pg_stat_activity WHERE state = 'active';"

Common Fixes

Issue Solution
Pool exhausted Increase max_connections
Auth failed Check .env credentials
SSL required Add ?sslmode=require to URL

External API Issues

Symptoms

Diagnostic Steps

1
2
3
4
5
6
7
8
# 1. Test basic connectivity
curl -v https://api.example.com/health

# 2. Check API key validity
curl -H "Authorization: Bearer $API_KEY" https://api.example.com/test

# 3. Check rate limit headers
curl -v https://api.example.com/resource 2>&1 | grep -i ratelimit

Common Fixes

Issue Solution
401 Unauthorized Refresh API key
403 Forbidden Check IP whitelist, permissions
429 Rate Limited Implement backoff, reduce rate
Timeout Increase timeout, check network

Network Debugging Tools

1
2
3
4
5
6
7
8
9
10
11
# DNS resolution
dig api.example.com

# TCP connectivity
telnet api.example.com 443

# HTTP tracing
curl -v --trace-time https://api.example.com

# SSL certificate
openssl s_client -connect api.example.com:443