- Newest
- Most votes
- Most comments
Based on the information provided, it seems you've taken many of the correct steps, but there are a few areas that may need adjustment:
-
Security Groups: Your setup for the security groups looks correct. However, ensure that the backend security group also allows inbound traffic from the frontend security group on the specific port the backend is listening on (5000 in this case).
-
ALB Configuration: Make sure your Application Load Balancers are configured correctly:
- The frontend ALB should route traffic to your frontend ECS tasks.
- The backend ALB should route traffic to your backend ECS tasks.
-
Target Groups: Confirm that your target groups are healthy and the health checks are passing.
-
Environment Variables: Double-check that the REACT_APP_API_URL environment variable in your frontend task is set correctly to the DNS name of your backend ALB.
-
Backend Error: The 500 status code suggests an internal server error on your backend. This could be due to:
- Incorrect routing in your backend application
- The backend not being able to connect to the database
- An error in your backend code
To troubleshoot further:
- Check the logs of your backend ECS tasks for any error messages.
- Verify that your backend can connect to the database.
- Try to access the backend API directly using the ALB DNS name to see if you get the same error.
- Ensure that your backend application is correctly configured to handle requests coming through the ALB (it may need to be aware of any path prefixes added by the ALB).
If you're still having issues, you might want to try:
- Using AWS ECS Service Connect instead of ALBs for service-to-service communication within your ECS cluster.
- Implementing proper error handling in your backend to provide more detailed error messages.
- Using AWS X-Ray or a similar tracing tool to get more insight into where the request is failing.
Remember to check your ECS task definitions, ensure all necessary environment variables are set, and that your containers are exposing the correct ports.
Sources
ECS EC2 and Postgres container connection by Service Connect | AWS re:Post
Connecting ecs fargate backend service to frontend nginx using service connect | AWS re:Post
Connect ECS Fargate Service/Task from public | AWS re:Post
Resolve HTTP connection errors with Application Load Balancer | AWS re:Post
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated 9 months ago

Thanks Sorry, I have one more question: how can I check the server -> rds-db connection? I think that's the problem.