Recently, I developed a Craft 3 website. Its working perfectly on development server. But after deploying to another server, I am getting 504 error for home and all front end pages while Craft dashboard is working perfectly. I looked into logs but didn't find anything related to it.
This is kind of hard to debug without any logs, but because 504 is a gateway timeout error, I would start by checking if your site uses any external services, other servers it tries to reach (only from within your templates, because the admin works fine).
This could be anything from Google's geolocation API to an external image service, that can not be reached because of server settings on either side.
Is there anything in your server logs, or could you activate logging for your server to get more details?
I was seeing similar issues and in the end it turned out to be a missing image. In my case it was the Creator (Entity Brand) logo missing. It had been picked but the file was missing locally. After reuploaded, it resolved the issues.
I wrote the issue here -> https://github.com/nystudio107/craft-seomatic/issues/418