Skip to content

AWS Lightsail load balancer 504 Gateway Time-out, website works fine behind the firewall

0

Hello - I have two different instances running a basic website; 1 is the "live" site running the Wordpress stack built on Bitnami. The second instance is a LAMP stack built up with a fresh Wordpress install, then I used WP migrate to bring over the old onto the LAMP stack with PHP 8.0 running.

New site successfully is up and running (I modified my spare laptop's host file to point to the new instance's IP address to update/test). Prior to switching load balancer to the new LAMP stack instance, all traffic to the current live site was fine. I added the new instance with PHP 8, removed the old instance from the load balancer. Everyhting worked for a few days. Then the new instance showed "504 Gateway Time-out" when loading the domain.

I added the old instance and removed the new one to go back to the original configuration. It worked fine for a few days, and now the load balancer is responding with "504 Gateway Time-out" to the old site also.

I am not sure what to do with the load balancer. It also has the SSL certificate on it. Any advice?

Thanks in advance!

Charles

1 Answer
1

Based on the information provided, it appears you're experiencing intermittent 504 Gateway Time-out errors with your AWS Lightsail load balancer. This issue can occur due to various reasons, and here are some steps you can take to troubleshoot and potentially resolve the problem:

  1. Check instance resources: Monitor the CPU and memory usage of your instances when the problem occurs. Lightsail instances have a burst capacity for CPU usage, and once this is exhausted, performance can drop, potentially causing timeouts. Consider upgrading your instance plan if you're consistently hitting resource limits.

  2. Verify application status: Ensure that your WordPress application is running correctly on both instances. Use the command "sudo netstat -tlnp" to check if the web server is listening on the correct ports (typically 80 and 443).

  3. Review load balancer health checks: Make sure your instances are passing the load balancer's health checks. If they're failing, the load balancer might not be able to route traffic properly.

  4. Check firewall settings: Verify that your instances' firewall rules allow inbound traffic on ports 80 and 443 from the load balancer.

  5. Examine WordPress and web server logs: Look for any error messages or unusual activity that might be causing the application to hang or timeout.

  6. Consider connection draining: If you're making changes to your instances, enable connection draining on your load balancer to allow in-flight requests to complete before removing an instance.

  7. SSL certificate: Ensure your SSL certificate on the load balancer is up-to-date and properly configured.

  8. Load balancer capacity: If you're experiencing high traffic, consider checking if you've reached the limits of your load balancer and if you need to scale up.

If the issue persists after trying these steps, you may need to contact AWS Support for further assistance. They can help you dive deeper into the load balancer logs and configurations to identify any underlying issues.
Sources
AWS Lightsail Gateway Timeout/Site unreachable | AWS re:Post
Troubleshoot a Classic Load Balancer: Response code metrics - Elastic Load Balancing
Troubleshoot Lightsail load balancer issues - Amazon Lightsail

answered a year ago
EXPERT
reviewed a year ago
  • Hello - thank you so much for your review of this issue. I have gone through each note, and the only one I cannot solve for is #3 - health check. It says that SSL traffic is taking too long to respond but I have an active and properly installed SSL cert on the load balancer. Both instances/sites work behind the load balancer. How do I reach AWS support?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.