Check the instances running behind your EC2 instances. They should be active and in running state. There are two possible reasons for this error:
- Either the load balancer is not able to able to reach the instances
- Or the webserver is not able to reach the backend web server which displays its own 502 error message.