the 504 indicates poor health of the vespa cluster. The description does not say whether this is a one-node or multi-node cluster - a common problem for many is a cluster too low on memory resources, so make sure the processes can run without failing. Checking vespa.log helps.
It helps knowing how you run the Vespa cluster, too (self-hosted or in Vespa cloud).
It also does not say if you can get some data, then a 504 / if all are 504.
https://vespa.ai/developer/ has some resources to help you, in particular the Community Slack, where it is easy to post your configuration and log/error messages + the the information missing above.