Dependency Unavailable
Error message
Error: Failed to connect to dependency service
Quick summary
The application cannot start or function because a service it depends on is not running or reachable.
Why this happens
The dependency service (database, cache, message queue) is not running
Network issues prevent the application from reaching the dependency
The dependency service URL or port is misconfigured
The dependency is in a different namespace or network and is not accessible
Minimal example
# App starts before database is ready
spec:
containers:
- name: app
image: myapp # crashes: DB not ready# Use init container to wait for DB
spec:
initContainers:
- name: wait-for-db
image: busybox
command: ['sh', '-c', 'until nslookup db-service; do sleep 2; done']
containers:
- name: app
image: myappThe app crashes because the database is not ready. The fix adds an init container that waits for the DB service to be available.
How to diagnose
Check if the dependency service is running:
kubectl get pods -l app=<dependency>Test connectivity from the application Pod:
kubectl exec <pod> -- curl <dependency-url>Verify the dependency URL and port in the configuration
Check Service and NetworkPolicy configurations
How to fix
Start or restart the dependency service
Fix the dependency URL or port in the configuration
Create a Service for the dependency if one does not exist
Adjust NetworkPolicies to allow traffic to the dependency
How to prevent
Use init containers to wait for dependencies before starting the app
Implement graceful degradation when dependencies are unavailable
Monitor dependency health and alert on failures