Reputation: 3928
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 ?
Upvotes: 336
Views: 920676
Reputation: 1377
I guess my case was very rare, but GitHub was out down. Check their webpage to see if it loads properly.
Upvotes: 0
Reputation: 501
For Windows user using TortoiseGit, see Settings-Network
, and enter proxy settings directly there.
Upvotes: 0
Reputation: 48
In my case problem was due to "Transfer ownership" of project to another Git user. When you do it, project URL changes from:
https://github.com/USER_1/repository.git
to:
https://github.com/USER_2/repository.git
Nevertheless it, project still accessible via old URL - so you can pull/push commits, without changing config. But, after ~1 year this URL become unreachable.
Solution:
git remote -v
- to see remotesgit remote set-url origin https://github.com/USER_2/repository.git
Upvotes: 1
Reputation: 538
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.
Upvotes: 1
Reputation: 846
I was able to fix this by unplugging my ethernet cable and plugging it back in. A reboot would probably work too, but this was the only way I could resolve it. The next thing I was going to try was a reboot.
Upvotes: -1
Reputation: 49
If you are using git from wsl guest vm on Windows host, and connected to a vpn on host to access github, then you may add github's ip address to windows host configuration to temporarily solve this problem. Because wsl2 has problem routing connection to vpn tunnel. Example, add following lines to C:\Windows\System32\drivers\etc\hosts
# used from wsl, need update periodically
20.205.243.166 github.com
20.205.243.168 api.github.com
Upvotes: 1
Reputation: 529
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.
Upvotes: 1
Reputation: 970
After restart git bash below works fine for me:
git push -f origin master
Upvotes: 3
Reputation: 79
Simply enter this command in your kali linux terminal before cloning repository:-
service NetworkManager start
Upvotes: 1
Reputation: 67
I had the same message and later I found out that the issue was that I was not connected to the VPN where the remote repo is...
Upvotes: 0
Reputation: 141
I solved it by using this command
$git config --global http.proxy http://enter_your_proxy:enter_port
Upvotes: 12
Reputation: 951
In my case (which was a private repo of git), host was suspended, so the issue was with my GitHub server and the administrator resolved it.
Upvotes: 0
Reputation: 2910
If all the above answers failed to solve your problem, try rebooting the router.
Upvotes: 1
Reputation: 909
Would like to note, when I did Brian's solution:
git config --global --unset http.proxy
Make sure to quit and restart terminal. Mine didn't resolve until I did that.
Upvotes: 55
Reputation: 813
In case your proxy server doesn't have username and password -
Change it like this-
192.168.49.1:8282
- <your-proxy-ip>:<port>
git config ---global http.proxy 192.168.49.1:8282
git config ---global https.proxy 192.168.49.1:8282
Upvotes: 1
Reputation: 496
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.
Upvotes: 13
Reputation: 222
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.
Upvotes: 3
Reputation: 113
I faced a different version of this problem while cloning the git repository via https:
fatal: unable to access 'https://GIT_USER:[email protected]/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.
Upvotes: 0
Reputation: 547
Maybe it is because of your internet access, You can try:
ping google.com
If you get this error again, there was problem in your network configuration.
Upvotes: 10
Reputation: 1328282
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:
px-v0.4.0.zip
anywhere you wantpx.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
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
Upvotes: 129
Reputation: 1075
If you have a VPN needed to connect to your enterprise account and do a "git pull" this error will occur, just switch on your VPN and it will work.
Upvotes: 2
Reputation: 731
Different from all these solutions, in my case, I solved the issue when I restarted my terminal (or open another window).
Upvotes: 0
Reputation: 2593
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:
Upvotes: 43