Deploying with capistrano fails – fatal: HTTP request failed. Requesting github, when set to bitbucket

So I’ve been deploying with Capistrano for quite some time now. Everything was good. Recently I ran into some issues.

The process was simple. I have a bitbucket account. I would push there and then cap would take the remote repo and then push it to the remote server. In doing so, upon using cap deploy I would be prompted twice for password; and actually, I don’t even really know why it asked me for a password twice (so perhaps this could have some light shed on it). Nonetheless, it worked for a long time, then it randomly stopped working. Upon requesting a password the second time, it was now saying fatal: HTTP request failed.

To make matters even more confusing, I looked over the process and it’s requesting a repo from a github after the second password prompt…and not bitbucket. There was a time when I used github, but that was in the past. So, I looked for a reference to the github repo in my Capfile and my deploy.rb, not finding any reference to it.

Where is this and why is it requesting it?
How can I fix this?

For reference, here is my deploy.rb (with sensitive info taken out of course):

set :application, "Application"
set :deploy_to, "/home/user/apps/app"
set :password, "webhostpassword"
set :user, "webhostuser"
set :domain, "webhostip"
set :deploy_via, :remote_cache
set :use_sudo, false 
set :scm, :git
set :repository,  ""
set :scm_username, "repousername"
set :scm_passphrase, "repopassword"

ssh_options[:forward_agent] = true

role :web, domain                           # Your HTTP server, Apache/etc
role :app, domain                           # This may be the same as your 'Web' server
role :db,  domain, :primary => true  

default_run_options[:pty] = true

namespace :deploy do
 task :start do ; end
 task :stop do ; end
 task :restart, :roles => :app, :except => { :no_release => true } do
  run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"

and here the output where it is failing:

servers: ["webhostip"]
[webhostip] executing command
** [webhostip :: out] Password:
** [webhostip :: out]
** [webhostip :: out] error: The requested URL returned error: 403 Forbidden
while accessing
** fatal: HTTP request failed
←[2;37mcommand finished in 18881ms←[0m

Notice line 6 and 7 where it is accessing github after it asks for the password (this is the second time a password prompt comes up upon using cap deploy

  • ruby fatal: Not a git repository WEIRD?
  • Git - Push to Deploy and Removing Dev Config
  • Rails code sharing: gem vs plugin vs submodule?
  • Internal Server Error no matter what I push to heroku app (Ruby on Rails)
  • How to display RoR app code version on heroku?
  • Capistrano failing to “git ls-remote …” with “no returned status code…”
  • Why my deployment check failing here
  • How to re-start cleanly with previous Git checkout, with correct files and migrations in Rails 3
  • One Solution collect form web for “Deploying with capistrano fails – fatal: HTTP request failed. Requesting github, when set to bitbucket”

    In my guess, capistrano will do a git pull origin <branch> instead of git clone <repo url> if the repo already exists on the remote server. Hence, it is still trying to hit github url.

    You can verify this by checking the .git/config file on your remote server. or by running git remote -v command. If origin is pointing to github, change that to bitbucket. Then manually run a git pull origin master command to ensure it is working

    Git Baby is a git and github fan, let's start git clone.