git, Heroku: pre-receive hook declined

Solution 1:

Make sure you are pushing a repo that contains a proper supported app ( Rails, Django etc.) and you are not just pushing some random repo to test it out.

Newbie in Heroku: Error when push my app to Heroku

If that is not the case and you are pushing what you think is a valid app, contact Heroku support and they will fix it for you.

Solution 2:

Make sure that you are using either npm or yarn.lock file-

Two different lockfiles found: package-lock.json and yarn.lock Both npm and yarn have created lockfiles for this application, but only one can be used to install dependencies.

After deleting yarn.lock and pushing the code again to git, my issue resolved.

Solution 3:

Deleting package-lock.json solved it for me

Solution 4:

I faced the same problem:

! [remote rejected] vX.X.XX -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:[application-name]'

I realized that my heroku application Stack is 'cedar-10' and was deprecated from 04/11/2014 and disabled from 04/11/2015 (Cedar-14 is now Generally Available).

The solution was to upgrade the heroku application Stack following the guide:

Upgrading the production app to Cedar-14

Solution 5:

Another issue could be that in a production environment, you can't use sqlite3, the default database when you make a rails app.

In order to fix this, just change the database your rails app uses to Postgres. This can easily be accomplished by editing your Gemfile

From your Gemfile, remove:

gem sqlite3;

and add the following:

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end