CodexBloom - Programming Q&A Platform

OCI Load Balancer Health Check scenarios with Custom Backend Configuration in Node.js

πŸ‘€ Views: 23 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-05
oci load-balancer nodejs JavaScript

Could someone explain I tried several approaches but none seem to work. I'm working on a project and hit a roadblock. I'm currently working on deploying a Node.js application on Oracle Cloud Infrastructure (OCI) and I've configured a load balancer to distribute traffic across two backend instances. However, I'm working with issues with the load balancer health check failing even though the backend service is up and running. I have set up the health check to query a specific endpoint that returns a simple JSON response. Here’s the configuration I used for the health check: ```json { "protocol": "HTTP", "port": 3000, "path": "/health", "intervalInMillis": 30000, "timeoutInMillis": 5000, "healthyThreshold": 2, "unhealthyThreshold": 2 } ``` The backend service is defined to respond to this health check on port 3000 with the following Node.js code: ```javascript const express = require('express'); const app = express(); app.get('/health', (req, res) => { res.status(200).json({ status: 'healthy' }); }); app.listen(3000, () => { console.log('Server running on port 3000'); }); ``` I verified that the backend instances are accessible and returning the expected response by sending a direct HTTP request using `curl`: ```bash curl http://<backend-instance-ip>:3000/health ``` This command returns the correct JSON response as expected. However, the load balancer dashboard shows the health check as 'unhealthy', and I see the following behavior in the OCI console logs: `Health check failed for backend set 'my-backend-set': 503 Service Unavailable` I've tried adjusting the health check path to a simple endpoint that returns a static string, but that didn't help either. I also checked the security list and ensured that the appropriate ports are open. I’m running this application inside a VCN with public subnet access. After all these attempts, I'm stumped as to why the load balancer fails the health checks. Any guidance on what I might be missing or additional troubleshooting steps would be greatly appreciated! Any ideas what could be causing this? My development environment is Linux. What am I doing wrong? I'm coming from a different tech stack and learning Javascript. I'm using Javascript latest in this project. I'd love to hear your thoughts on this. For context: I'm using Javascript on Debian. Thanks for taking the time to read this!