Search code examples
gitproxybitbucketgit-bashgit-clone

Received HTTP code 501 from proxy after CONNECT


Whenever I try to clone a repository from bitbucket, it gives me following error:

fatal: unable to access 'https://[email protected]/user_name/repo_name.git/': Received HTTP code 501 from proxy after CONNECT

Can't understand what is the problem. I am copying git clone command from bitbucket repository web. I have also set git http.proxy but it didn't work.

Let me know if more information is required.

Thanks


Solution

  • Obviously, your proxy doesn't support HTTP CONNECT tunneling, that's why it responds with HTTP 501 (Not implemented) code:

    HTTP CONNECT tunneling

    A variation of HTTP tunneling when behind an HTTP Proxy Server is to use the "CONNECT" HTTP method.

    In this mechanism, the client asks an HTTP Proxy server to forward the TCP connecting to the desired destination. The server then proceeds to make the connection on behalf of the client. Once the connection has been established by the server, the Proxy server continues to proxy the TCP stream to and from the client. Note that only the initial connection request is HTTP - after that, the server simply proxies the established TCP connection.

    This mechanism is how a client behind an HTTP proxy can access websites using SSL (i.e. HTTPS).

    Not all HTTP Proxy Servers support this feature, and even those that do, may limit the behaviour (for example only allowing connections to the default HTTPS port 443, or blocking traffic which doesn't appear to be SSL).