Search code examples
githerokudeploymentheroku-cli

How to fix long-running `git push` to Heroku remote responding `504 GATEWAY_TIMEOUT`?


I'm trying to do a git push (force) for a branch to a git repo hosted on Heroku.

This is unfortunately timing out after a long wait. I've tried it a number of times with the same 504 GATEWAY_TIMEOUT error:

$ git push --force my-heroku-remote my-feature-branch:master
Counting objects: 12345, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (12345/12345), done.
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 GATEWAY_TIMEOUT
fatal: The remote end hung up unexpectedly
Writing objects: 100% (12345/12345), 347.86 MiB | 98.00 KiB/s, done.
Total 12345 (delta 123), reused 1234 (delta 123)
fatal: The remote end hung up unexpectedly
Everything up-to-date

How can I push to this remote successfully?


Solution

  • Heroku support advised resetting the remote repo which successfully fixed the issue. Be absolutely certain you are performing this on the correct heroku app/repo BEFORE you run this command:

    heroku repo:reset -a my-heroku-app
    

    After running the above command, the git push worked without error.

    This uses the Heroku CLI repo plugin, which you may need to install: https://github.com/heroku/heroku-repo#reset