26

Am getting the following error while trying to pull/push or create new-clone

error: couldn't connect to host while accessing https://github.com/user/pack.git/info/refs fatal: HTTP request failed

when i googled, people suggested to setup http_proxy.. but i don't understand it or i don't know to setup it.. am totally stuck up with it..

i don't know how to overcome these issues..

any help would be appreciated..

NB: note that i was able to use git before couple of days.. in the last couple of days it has been screwed up.. please help..

user717787
  • 269
  • 1
  • 4
  • 5
  • To help diagnose where exactly the issue is, can you create a brand new githib repository, clone it, make a change an d push and pull ok? – Michael Durrant Aug 10 '12 at 12:53
  • i can't even create a new clone, am facing the same issue when i tried to do a new clone.. seems some git settings is screwed up.. but don't know exactly.. – user717787 Aug 10 '12 at 16:21
  • I'm voting to close this question as off-topic because it's a generic network or server issue that has nothing to do with git. – Gilles 'SO- stop being evil' Jan 06 '16 at 09:18
  • If everything is fine and configured as you said, then its may be a DNS cache issue that can be fixed by running this command 'ipconfig/flushdns' in your command prompt window, to clear DNS cache. I have fixed it this way. – Hassan Jamil Jan 19 '17 at 12:26
  • I had the same problem with the clones from gitlab-ci runner on an old CentOS box. Upgrade ```nss curl libcurl```, solves the problem. Seems the same problem mentioned [here](https://stackoverflow.com/questions/12538130) – isca May 17 '19 at 17:42

9 Answers9

15
git config --global --unset http.proxy 
git config --global --unset https.proxy

works for me

Jens
  • 67,715
  • 15
  • 98
  • 113
Léon Jiresse
  • 621
  • 9
  • 18
7

This happened to me on my Vagrant VirtualBox VM running Ubuntu 12.04. The vagrant instance had been up for several days. I restarted the VM (vagrant reload), ssh'd back in, and it worked.

What's the cause? Not sure. Someone else can speculate. However, I always like to reboot three times just to be sure ;)

Bill Paetzke
  • 13,332
  • 6
  • 44
  • 46
6

I've faced the same error when I changed the network that my laptop was connected. Editing /etc/resolv.conf properly solved the problem:

nameserver 8.8.8.8

Making resolv.conf blank and reboot might solve it too.

On debian 2.6.32-5-amd64 + VirtualBox 4.2.12.

Nobu
  • 9,965
  • 4
  • 40
  • 47
3

I gave the follwoing command to restart my network services. This would work for sure:

service network restart
Vivek S
  • 5,384
  • 8
  • 51
  • 72
2

One solution, if this is a repository under you control, would be to use an SSH key for your repository access instead of HTTP. Update your remote accordingly by dropping the origin remote with:

git remote rm origin
git remote add origin <ssh_path_from_github>

You can find the ssh path in github here:

SSH github access

Make sure to preface it with ssh:// when you re-add the remote. If this doesn't work then we'll look at the http proxy settings, but based on your faux github link, I'm hoping it's a repository under your control.

Christopher
  • 42,720
  • 11
  • 81
  • 99
  • I tried that as well... it failed at doing the ssh test, when i ran "ssh git@github.com", it said: $ ssh git@github.com ssh: connect to host ssh.github.com port 22: Bad file number i tried these with the gitbash.. now i don't know how to proceed.. i googled and found some links but those didn't help either.. – user717787 Aug 10 '12 at 16:22
  • Sorry, said what? I think your copy/paste got munged. – Christopher Aug 10 '12 at 16:23
  • when executed from Git-bash i got the following errors Charles@HARD-FX /d/ror/Pack (master) $ git pull error: couldn't connect to host while accessing https://github.com/user/Pack.git/info/refs fatal: HTTP request failed $ ssh git@github.com ssh: connect to host ssh.github.com port 22: Bad file number – user717787 Aug 10 '12 at 16:30
  • Google suggested [this answer](http://stackoverflow.com/a/8019448/877115) for that ssh problem. – Christopher Aug 10 '12 at 16:37
  • even tried doing that n i get the following message: Charles@HARD-FX /d/ror/Pack (master) $ ssh -vT github.com OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007 debug1: Reading configuration data /c/Users/Charles/.ssh/config debug1: Applying options for github.com debug1: Connecting to ssh.github.com [207.97.227.248] port 443. debug1: connect to address 207.97.227.248 port 443: Not owner ssh: connect to host ssh.github.com port 443: Bad file number – user717787 Aug 10 '12 at 17:02
2

I have experienced the same error when wanted to push code on github. The problem was that I had messed up some environment variables on my Ubuntu machine. This happened because I wanted to use a manual proxy on google chrome.

If you are using linux use the following command to see if http_proxy and https_proxy are set to some ip address.

env | grep http_proxy

Then use the following commands to unset the value of these two variables.

unset http_proxy
unset https_proxy

Try to use git again. If it does not work then do a reboot. It worked for me.

orthodoxpirate
  • 1,934
  • 2
  • 17
  • 17
0

My extremely simple solution was to first clone the empty new repo. I then deleted the .git folder in my project and moved all my project files & folders into the new repo folder. I then changed directories into that folder and then ran the add, commit, and push commands. Everything worked well.

Before trying this solution, I had not cloned the git repo first. My project folder and the repo had the same name, I had run git init, add, commit, and set the upstream, but push was giving me an error (failure to connect to host).

macsplean
  • 611
  • 3
  • 8
  • 22
0

I was getting a similar error in Visual Studio 2013:

An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error).
An error occurred while sending the request.

Then I tried using Git GUI:

Pushing to https://leniel@bitbucket.org/myrepo/bhp.git
error: Couldn't resolve host 'bitbucket.org' while accessing https://leniel@bitbucket.org/myrepo/bhp.git/info/refs?service=git-receive-pack
fatal: HTTP request failed

Guess what... my Parallels Virtual Machine had no internet connection at the moment. After reestablishing the internet connection I could push my commit. :) Can't believe that happened. We're so used to have an internet connection always on.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

I got same error when try to pull using different linux user.

ls -lah
whoami

Make sure current user is same as owner of that folder.

Pavel Evstigneev
  • 4,918
  • 31
  • 21