- Newest
- Most votes
- Most comments
The 504 Gateway Timeout error you're experiencing with your WordPress instance on AWS Lightsail is a common issue that can occur due to several reasons. Based on your description, here are some potential causes and solutions:
-
Resource constraints: Your current instance specification (2 vCPUs, 1GB RAM) might be insufficient for your WordPress site's needs, especially during periods of high traffic or resource-intensive operations. Lightsail instances have a burst capacity for CPU usage, but once this is exhausted, performance can drop significantly. Consider upgrading to a larger instance size if you consistently face this issue.
-
CPU and memory usage: Monitor your instance's CPU and memory usage when the problem occurs. If you notice high usage, it could indicate that your site is hitting resource limits, causing the timeout.
-
WordPress configuration: Ensure that your WordPress installation, themes, and plugins are up-to-date and optimized. Some plugins or poorly optimized themes can cause excessive resource usage.
-
Database issues: Check if there are any database-related problems, such as slow queries or a large number of concurrent connections, which could lead to timeouts.
-
PHP settings: Review and adjust PHP settings like max_execution_time in php.ini to allow for longer script execution times if necessary.
-
Web server configuration: Check Apache or Nginx configurations for timeout settings and adjust if needed.
-
Caching: Implement a caching solution to reduce the load on your server and improve response times.
-
Content Delivery Network (CDN): Consider using a CDN to offload some of the traffic from your Lightsail instance.
If the issue persists after trying these solutions, you may want to consider creating a new WordPress instance with the latest software stack and migrating your content to it. This can sometimes resolve compatibility issues with older instances.
Remember to regularly back up your data and monitor your instance's performance to quickly identify and address any issues that arise.
Sources
AWS Lightsail Gateway Timeout/Site unreachable | AWS re:Post
Wordpress install script gives 504 error on Lightsail LAMP stack | AWS re:Post

This guide provides further details about where to find the metrics and what to look for: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-viewing-instance-health-metrics.html
If your CPU utilization is high, consider whether you've added any plugins more recently that could be inefficient or doing a lot of work. If you are receiving a lot of web traffic, consider using a caching plugin to reduce the work required to render each page view.