Error 504 gateway timeout

My WordPress websites give me this error.

I have a VPS with 8vCPU and 8GB of RAM.

What configuration and logs should I review to find out where the problem may be?

Apache is down
MySQL is down
PHP is down

Restart them one by one to see what restart makes everything work again

Checking the website logs I get this

[Fri Dec 27 12:25:06.195998 2024] [proxy_fcgi:error] [pid 1229:tid 1267] (70007)The timeout specified has expired: [client xx.22.xxx.30:0] AH01075: Error dispatching request to : (polling) , referrer: https://dominio.cu

[Fri Dec 27 12:30:41.179615 2024] [proxy_fcgi:error] [pid 1230:tid 1268] (70007)The timeout specified has expired: [client xx.15.xxx.27:0] AH01075: Error dispatching request to : (polling) , referrer: https://dominio.cu

[Fri Dec 27 12:41:41.543836 2024] [proxy_fcgi:error] [pid 1230:tid 1270] (70007)The timeout specified has expired: [client xx.22.xxx.30:0] AH01075: Error dispatching request to : (polling) , referrer: https://dominio.cu

[Fri Dec 27 12:47:48.829451 2024] [proxy_fcgi:error] [pid 1230:tid 1246] (70007)The timeout specified has expired: [client x.212.xxx.62:0] AH01075: Error dispatching request to : (polling) , referrer: https://dominio.cu

The websites give errors at times, it is not that it goes down for a long period where you can restart the services to find which one is causing the problem.