Git ssh could not resolve hostname
Solution 1
SSH doesn't work with an HTTP/HTTPS proxy. If your proxy supports SOCKS, you may be able to use git via SOCKS using a wrapper like tsocks or socksify or a redirection tool like redsocks. Those are options for Linux; on Windows maybe something like Widecap will help. Here's a more comprehensive overview of tools that may be suitable: https://en.wikipedia.org/wiki/Comparison_of_proxifiers
Alternatively, Git supports HTTP, too, and so does BitBucket, as far as I know. Hence, it might be worth trying the URL with https://
instead. Example: https://youruser@bitbucket.org/youruser/yourrepository.git
Solution 2
I faced similar issue and landed up here. In my case one of my local gitlab project was throwing below error for push/pull. Other gitlab projects under same group were working fine.
ssh: Could not resolve hostname gitlab.com: nodename nor servname provided, or not known.
Fix :
In file <PROJECT_FOLDER>/.git/config
url was like url = ssh://[email protected]
Removing ssh://
from url worked for me.
Niklas
Updated on June 22, 2022Comments
-
Niklas almost 2 years
If I want to clone a Git repository via SSH, I get:
ssh: Could not resolve hostname bitbucket.org: nodename nor servname provided, or not known fatal: Could not read from remote repository.
I need to use a proxy to connect to the internet. (proxy:8080)
In Git I can easily set the HTTP and HTTPS proxy via:
git config --global http.proxy http://proxy:8080/ git config --global https.proxy http://proxy:8080/
How can this be achieved for SSH?