The error -504 is caused by a timeout while communication with the Google server. The main problem is a slow internet connection.

Solution:

  • Faster internet connection via WiFi

  • Reset of Google Play:
    - Settings > Apps > Google Play Store > Storage > Clear Data & Clear Cache
    - Settings > Apps > Google Play Services > Manage Space > Clear All Data

  • Reset of you Google account:
    -  Settings > Accounts > Google > Account preferences > Delete your Google Account
    (Then restart your device and login again)
    - Settings > Accounts > Add account > Google

  • Restart your device