23

I have a remote repository with HTTPS access.

git status lists only one entry: master

git remote -v lists two entries to the same address: one for fetch, one for push

But when I do git remote show origin, or other operations, like fetch, I get :

error: while accessing https:...
fatal: HTTP request failed

I am behind a proxy, but as it is set in my .gitconfig (sslVerify = no) and the cloning is OK, I don't think the problem comes from that.

BUT... my OS (CentOS) has been reinstalled.

Oodini
  • 1,092
  • 6
  • 11
  • 22
  • 1
    Can you share the first 6 characters of the urls `git remote -v` for the origin, esp. the protocol used - http, https, ssh or git? – First Zero Jan 04 '12 at 06:16

3 Answers3

34

If you're using https: rather than git: for your clone, it's possible that it's barfing on the CA certificate, i.e. you don't have a copy of the intermediate certificate to verify your SSL connection. I've run into this on a couple of different occasions. Usually with debian-based Linux distributions. Try

git config --global http.sslVerify false

and then the clone again. If the clone works, that's what's happening. However this is a bad solution, as of course turns off SSL verification, which makes using HTTPS somewhat pointless, and leaves you vulnerable to man-in-the-middle attacks.

What you need to do is download the CA Certificates package for whatever OS you're on, under Linux (well Debian/Ubuntu) it'll probably be something like

apt-get install ca-certificates

then

git config --global http.sslVerify true
git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt

although your path to your certificate file might be different depending on OS version.

This should get it working.

Alasdair Allan
  • 2,134
  • 2
  • 18
  • 18
  • The other thing you'll need to do on the Beaglebone is enable ntp. Angstrom linux ships with no ntp installed, and the Beaglebone has no battery backed up clock. That means that the date is set on boot to Jan 1 2000. This causes all sort of problems, including making SSL certificates invalid. – Alasdair Allan Dec 08 '13 at 00:28
  • i have a simmilar problem: https://superuser.com/questions/1323649/git-ls-remote-throws-fatal-http-request-failed but turning off ssl verification didn't worked. – Alfredo M May 18 '18 at 15:54
3

I had set the http proxy in the http_proxy environment variable (Git Bash on Windows), but only setting the proxy in my %HOME%/.gitconfig worked:

[http]
    proxy = http://USERNAME:PASWORD@URL:PORT
Joachim Werner
  • 166
  • 1
  • 6
  • 2
    Environment variables are case sensitive and it is correctly lower-cased as `http_proxy`. (Some software of course handles both, but some does not!) – Edward Thomson Jun 25 '13 at 14:19
0

I've got the same error, but quite other problem than mentioned in the rest answers. I was trying to clone repository on linux:

git clone http://xxx/scm/xxx/xxx.git
Initialized empty Git repository in /opt/git/xxx/.git/
Password:
error: Failed connect to xxx:80; Operation now in progress while accessing http://xxx.git/info/refs

fatal: HTTP request failed

It was all because wrong permissions to folder - but git instead of some permissions error throws HTTP request failed. So if someone will encounter similar problem - check folder permissions!

mdziob
  • 1,116
  • 13
  • 26