-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
backendBackend/API relatedBackend/API relatedbugSomething isn't workingSomething isn't workinginfrastructureInfrastructure and deploymentInfrastructure and deployment
Milestone
Description
Problem Description
When restarting only the backend container using make restart-backend or docker compose restart backend, the backend loses its connection to the frontend container, resulting in a 502 Bad Gateway error when attempting to login via the frontend.
Steps to Reproduce
- Start the full application:
make run-appordocker compose up -d - Verify both frontend and backend are working properly
- Restart only the backend:
make restart-backendordocker compose restart backend - Try to login via the frontend (browser at
localhost:3000) - Observe 502 Bad Gateway error
Expected Behavior
Restarting the backend container should maintain proper connectivity with the frontend container. The nginx reverse proxy in the frontend should continue to properly route /api/* requests to the backend container.
Current Workaround
Currently need to restart both containers to restore connectivity:
make restart-app
# or
docker compose restart backend frontendTechnical Details
Container Setup:
- Frontend: nginx serving React app on internal port 8080, exposed to host on port 3000
- Backend: FastAPI on internal port 8000, exposed to host on port 8000
- Network: Both containers on
app-network
nginx Configuration in Frontend (webui/default.conf):
location /api/ {
proxy_pass http://backend:8000;
# ... proxy headers
}docker-compose.yml Dependencies:
frontend:
depends_on:
backend:
condition: service_healthyPossible Root Causes
- nginx Connection Caching: nginx might be caching the backend connection and not detecting the backend restart
- Docker Network Issues: Container restart might cause network connectivity issues within
app-network - Health Check Timing: Frontend might not wait for backend to be fully healthy after restart
- nginx Upstream Configuration: Missing upstream configuration or connection pooling issues
Proposed Solutions
- Improve nginx Configuration: Add upstream block with proper health checking
- Add nginx Reload: Modify
make restart-backendto reload nginx configuration in frontend - Fix Container Dependencies: Ensure proper container restart order and health checking
- Add Connection Retry: Configure nginx to retry failed backend connections
Environment
- Docker Compose version: Latest
- Container setup: nginx (frontend) + FastAPI (backend)
- Network: Custom bridge network
app-network - Platform: macOS/Linux
Priority
Medium - Affects development workflow when debugging backend issues requiring container restarts.
Labels
buginfrastructuredockernginxdevelopment
Metadata
Metadata
Assignees
Labels
backendBackend/API relatedBackend/API relatedbugSomething isn't workingSomething isn't workinginfrastructureInfrastructure and deploymentInfrastructure and deployment