Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

What I did: I have created a remote repository on Github and I am trying to clone the remote repository on my local machine. While cloning I am providing the clone URL & target folder.

But every time I try to clone, I am getting this error:

Error: "fatal: unable to access ' https://github.com/hyperion057/spring-repo.git/ ': Could not resolve host: github.com"

What do I need to do to connect to GitHub ?

What command are you using? Are you cloning by https or ssh ? I just tried to clone your project and it worked. Raul Rene Dec 4, 2013 at 8:21 The errors you are getting are basically telling you it cannot connect. You have probably set your proxy to the browser, but not on the entire machine. Try to set the proxy accordingly and try again. Raul Rene Dec 4, 2013 at 9:24

I got a similar error, and it's caused by incorrect proxy setting. This command saved me:

git config --global --unset http.proxy

https version:

git config --global --unset https.proxy
                This is worth trying even if you never touched the proxy setting and aren't behind one currently. I think this was somehow set automatically during a past hotel stay (or when using in-flight wifi) where a proxy was in place.
– Shawn Erquhart
                Mar 24, 2015 at 16:51
                Note that this will only unset the HTTP proxy. If you're having difficulty connecting to HTTPS locations, use the sister command 'git config --global --unset https.proxy'
– degs
                Jul 11, 2015 at 5:43
                This solved my problem. I was getting an error from homebrew "fatal: unable to access 'github.com/caskroom/homebrew-cask': Could not resolve proxy: wpad" and this resolved it.
– amatusko
                Jul 31, 2015 at 12:45
                I never touched the proxy settings, didn't change any of my previously working settings, and have never even used a proxy. But this is what worked to fix my problem. Thank you.
– SummerEla
                Sep 11, 2015 at 21:05
                lol, that was the problem at my end too. I had my browser open in another computer (it sucks the life out of my work Mac otherwise). And I was looking for the solution in another PC. Didn't notice that the work computer had got disconnected.
– Nitin Nain
                Jan 28, 2016 at 5:56
                If you are conncted to VPN, one of the tricks is definately to re-connect again. Thanks a much, that saved my life.
– Sachidananda Naik
                Apr 28, 2020 at 13:04
                I did not do anything apart from switching my wifi on and off multiple times (on my laptop). After around 40 seconds past the last on/off the issue resolved.
– Evgenia Karunus
                Jun 22, 2020 at 19:24
                My default DNS provider sucks so I usually set up Google for DNS resolution. 8.8.8.8 and 8.8.4.4
– Roberto Decurnex
                Feb 17, 2021 at 13:03

do i need to configure proxy settings? because my office has got proxy servers.

Yes, you can do so by setting HTTP_PROXY, and HTTPS_PROXY environment variables.

See "Syncing with github":

set HTTPS_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set HTTP_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set NO_PROXY=localhost,my.company

(To avoid putting your credentials -- username/password -- in clear in the proxy URL, see below)

Note the NO_PROXY, to allow to access internal site to your company

You also can register that in your git config:

git config --global http.proxy http://<login_internet>:<password_internet>@aproxy:aport

But if you have incorrect proxy Git settings, remove them:

cd /path/to/repo
git config --unset http.proxy
git config --global --unset http.proxy
git config --system --unset http.proxy
git config --unset https.proxy
git config --global --unset https.proxy
git config --system --unset https.proxy
# double-check with:
git config -l --show-origin | grep -i proxy

No credentials needed: use genotrance/px.
If you are, as I am, in a company behind a NTLM proxy, all you need to do is:

  • unzip px-v0.4.0.zip anywhere you want
  • change the px.ini config file (put it in %USERPROFILE%), chaging the server line:
    [proxy]
    server = proxy.my.company:8080  <= use your company proxy:port
    listen = 127.0.0.1
    port = 3128
    
  • use HTTP(S) proxy variable without your credentials! (the px proxy will reuse the ones from the current Widows session, either through Microsoft SSPI or Microsoft Kerberos)
  • That will give you:

    set HTTPS_PROXY=http://127.0.0.1:3128
    set HTTP_PROXY=http://127.0.0.1:3128
    set NO_PROXY=localhost,my.company
                    This isn't always the issue. See my answer below, but sometimes if you mac is out of disk space you need to delete a few files and restart the terminal.
    – scosman
                    May 9, 2017 at 17:37
                    @CătălinaSîrbu What part is unclear? My setting regarding http_proxy is done with the commands at the end of this answer.
    – VonC
                    Aug 24, 2020 at 15:47
    

    another possibility, I ran into this problem myself. But it was after I had installed a VPN (which was unrelated and running)

    turning off the VPN, fixed the issue.

    for the record, I was running "Viscosity" VPN on my MacBookPro

    I've had the same issue after running out of disk space. Closing and reopening terminal fixed it one time. Restarting my Mac the next.

    Some easy things to try before jumping to random commands:

  • restart terminal tab
  • restart terminal app
  • If disk is full (or close to it) free up some disk space then restart terminal app
  • restart machine/OS
  • Restarting my mac worked, but it looks like just restarting my terminal might have been sufficient. I hope people see this, because I went on a mini wild goose chase for about 20 minutes trying the various commands on this and other help sites. – Jacob Crofts Feb 12, 2017 at 1:30 I was facing this problem on WSL2/Ubuntu and only your solution - restarting OS (windows) - solved this problem. Thank you. – siruku6 Apr 23, 2022 at 8:26 Current IP Addresses are listed here: api.github.com/meta (from help.github.com/articles/about-github-s-ip-addresses) and here is a tool to convert CIDR to ip range : ipaddressguide.com/cidr – Ashutosh Jindal Nov 9, 2018 at 12:16

    From the answer here -> my solution is specific for Windows Subsystem for Linux (WSL) users. None of the answers relating to proxies are relevant to my solution.

    If you are unable to run a ping command e.g.

    # WSL
    ping google.com
    

    Then it is likely your file at /etc/resolve.conf is corrupt. To fix this run the following in a WSL window:

    # WSL
    sudo rm /etc/resolve.conf
    

    Then open a Powershell terminal in Administrator mode and run

    # Powershell
    wsl --shutdown
    Get-Service LxssManager | Restart-Service
    

    This should fix the problem, which can be tested by running the ping command again.

    In my case, on a Windows box, my TCP/IP stack seems to have needed to be reset. Resetting the TCP/IP stack of the client PC caused git to start behaving properly again. Run this command in Administrator mode at a command prompt and retry the git command:

    netsh int ip reset
    

    Manually disabling and re-enabling the network adapter via the Control Panel produces a similar result.

    I suspect DNS resolution problems inside the TCP stack on my Windows box.

    C:\wamp\www\myrepository [master]> git push
    fatal: unable to access 'https://github.com/myaccount/myrepository.git/': Couldn't resolve host 'github.com'
    

    Actually, the prompt message has told us where's wrong.

    https://github.com/myaccount/myrepository.git/
    

    When I check my github, I found my github repository's HTTPS url is

    https://github.com/myaccount/myrepository.git
    

    I don't know how this happened. The wrong url has been set up by installed Git Shell automatically.

    Once I remove the '/' at the end, I can push successfully.

    Hi John - Can you provide details as to how you removed the '/' ? I'm having the same issue you describe above. – user1259823 Oct 21, 2016 at 18:12 git remote -v to see the remotes. git remote set-url origin https://github.com/USERNAME/REPOSITORY.git to set the remote. – Viktor Sec Mar 7, 2018 at 8:15 Even I have the same issue. I don't see "/" with git remote -v, but I see is while doing git push. How to solve this? – Kalyanam Rajashree Jun 4, 2018 at 9:13

    Just in case future generations stuck in this too: For me what worked (on mac OSX) was to set my DNS with opendns 208.67.222.222 , 208.67.220.220. I get this numbers here: https://www.opendns.com. For some reason, my dns configuration reseted to the default numbers (my local ip I guess), and I was not able to connect to neither github, brew or rubygems. Sorry for the misspelling.

    Edge case here but I tried (almost) all of the above answers above on VirtualBox and nothing was doing it but then closing not only the VirtualBoxVM but good ole VirtualBox itself and restarting the program itself did the trick without 0 complaint.

    Hope that can help ~0.1% of queriers : )

    Figured a ctrl-F "virtual" would find this... Nice to see you friend :-) Just did the same fix -- needed to restart the VM and VB, then all was well. Imagine something got messed up while playing with buffer overflows in some server code on the VM :P – killian95 Sep 17, 2021 at 15:21

    One reason for this issue could be wrong/empty /etc/resolv.conf file.

    The way I resolved this issue in my centos 7 minimal is as follows: my /etc/resolv.conf was empty and I added the following lines:

    nameserver 192.168.1.1
    nameserver 0.0.0.0
    

    where 192.168.1.1 is my gateway, in your case it can be different.

    I ran command on terminal, then restarted terminal.

    git config --global --unset https.proxy
    

    But it din't work. Then I turned Off and On my wifi on Mac.

    git push
    

    It worked.

    As a suggestion for Ubuntu servers, you can write down essid and password of router in your /etc/network/interfaces file:

    iface [en0 || your wireless driver no necessarily en0] inet static
        address 192.168.1.100 / (something for your static ip between 1-255)
        netmask 255.255.255.0
        gateway 192.168.1.1 / (this is the ip of your router)
        dns-nameservers 8.8.8.8 / (you can use whatever you want)
        wpa-ssid qwertyuio / (this is router id)
        wpa-psk qwertyuio / (this is router password for wireless connection)
    

    When I got this error while pulling a repository to my server, I wrote wpa-ssid and wpa-psk and restarted. Then it worked.

    EDIT: I faced the same issue again and this time it was because of the inconsistency in router signal levels. My connection was not strong, that was the problem. However, the solution above is a real solution for static ip

    After clearing the Empty cache and hard reload from the Chrome dev tool of https://github.com/ thats works for me.

    Open your Chrome dev tool and right click on reload icon, then you can see this option.

    In my specific case, there's a software called ZScaler that was blocking access to the internet. Restarting it fixed it. I suppose you need to try to restart your PC before setting proxies and all the other stuff, as the nature of the problem might be simpler than you think. Sometimes it is just no access to the internet.

    I guess my case was very rare, but GitHub was out down. Check their webpage to see if it loads properly.

    GitHub

    I faced a different version of this problem while cloning the git repository via https:

    fatal: unable to access 'https://GIT_USER:GIT_PASSWORD@github.com/organization/repo.git/': Could not resolve host: GIT_USER

    The problem was there were restricted characters in the password and it needs to be URL encoded. Additionally, if you are using 2FA (two factor authentication) then personal access token should be used in place of the password.

    Searching the error condition above yields this page on google, so hopefully this answer will save someones time.

  •