Why this happens

The server is taking too long to generate a response, so the connection itself times out before any page - even an error page - can be returned. This is different from a PHP execution timeout; it usually points to server-level resource exhaustion, very high traffic, or a runaway process consuming CPU.

Step-by-step fix

  1. Disable recently installed plugins, especially backup or security plugins that run heavy scans.
  2. Optimize your database (you can use a plugin like WP-Optimize, or do it manually via phpMyAdmin).
  3. Ask your hosting provider about the status of your server resources (CPU/RAM).
  4. If you're on shared hosting and your site is large, consider a VPS or a better hosting plan.

How to prevent it happening again