Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not resolve host: github.com #4872

Closed
shiv1490 opened this issue Jun 5, 2018 · 95 comments
Closed

Could not resolve host: github.com #4872

shiv1490 opened this issue Jun 5, 2018 · 95 comments
Labels
more-info-needed The submitter needs to provide more information about the issue

Comments

@shiv1490
Copy link

shiv1490 commented Jun 5, 2018

Description

I create a new repository in my local and complete the changes . After that I opened my github desktop to push the changes to my GitHub repo. As soon as i click the publish button it gave me this error

Version

  • GitHub Desktop:1.22
  • Operating system: windows 10 64 bit

Steps to Reproduce

Expected Behavior

Should publish new repository

Actual Behavior

gave this error - fatal: unable to access 'https://github.com/shiv1490/Burger-Builder.git/': Could not resolve host: github.com

Additional Information

Logs

@niik
Copy link
Member

niik commented Jun 5, 2018

Hey @shiv1490. This error message seems to indicate a connectivity problem. Do you currently have any antivirus software installed other than the default antivirus that ships with Windows?

Additionally, are you using a proxy server to access the internet? Git requires special configuration to work behind proxy servers, see #1998, #2789

@niik niik added the more-info-needed The submitter needs to provide more information about the issue label Jun 5, 2018
@shiv1490
Copy link
Author

Hi All,
Issue is resolved now. This was happening because I was behind a corporate proxy. I used below commnad to resolve the issue

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

Thanks

@Jaaess
Copy link

Jaaess commented Jun 22, 2018

@shiv1490 👍
the command worked with me.
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

@imsrgadich
Copy link

Check this out as well. it helped me.

git config --global --unset http.proxy 
git config --global --unset https.proxy

@DoganM95
Copy link

DoganM95 commented Nov 27, 2018

in my case it was a firewall rule (cmd not having internet permission), created by the company i work for

@kutajay
Copy link

kutajay commented Feb 3, 2019

Tried the following
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 and
git config --global --unset http.proxy
git config --global --unset https.proxy
but none seems to work for me; could it be a possible internet strength isssue?

@SethuSP
Copy link

SethuSP commented Apr 4, 2019

Tried the following
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 and
git config --global --unset http.proxy
git config --global --unset https.proxy
but none seems to work for me; could it be a possible internet strength isssue?

I too tried the same. It does not work for me as well and i do not think it is related to internet strength. Not sure why.

@JCDigital27
Copy link

This method works for me!
reboot>
then establish connection to internet...
then>
#git config --global --unset http.proxy
#git config --global --unset https.proxy
then>
#git clone https://(.........................................).git

@davidbeery
Copy link

Why does this fix work?
What is it about the http/s.proxy global config that interferes with the internet connection?

@steveward
Copy link
Member

@davidbeery The --unset flag can fix the issue where Git will attempt to establish a connection through an invalid proxy configuration (i.e. the user is actually not behind a proxy), which causes Git operations to error out. If you are using a proxy then you will want to keep that proxy configuration line in order to ensure Git operations work successfully.

@RoderickKennedy
Copy link

@JCDigital27 i have the same problem, whe i use the solution, but it not work?
when i use curl -I https://github.com, it show the error.
curl: (6) Could not resolve host: github.com; Unknown error

@manishak-kumari
Copy link

@shiv1490 👍
the command worked with me.
git config --global http.proxy http://proxyuser:proxypwd@proxy.servers
should i copy and paste the same line given by you above or i need to do some change?

@sadkisoft
Copy link

sadkisoft commented Sep 19, 2019

Please i need a help
My code is :

$url="https://api.sellercenter.net/?Action=GetProducts&UserID=***&Signature=***&Format=JSON";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));

	$parsee = curl_exec($ch);
	$result=json_decode($parsee,false); 
	$errno = curl_errno($ch);
	$errmsg = curl_error($ch);
	$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
	var_dump($errno, $errmsg, $httpcode, $parsee);

the result is 👍
int 6
string 'Could not resolve host: api.sellercenter.net; Host not found' (length=60)
int 0
boolean false

@steveward
Copy link
Member

@sadkisoft this issue tracker is for GitHub Desktop -- if you have specific programming questions I'd recommend our Community Forum or StackOverflow.

@keshri1
Copy link

keshri1 commented Dec 25, 2019

Check this out as well. it helped me.

git config --global --unset http.proxy 
git config --global --unset https.proxy

This helped buddy

@Preethi-Sanga
Copy link

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
its not worked for me

@pdkproitf
Copy link

Check this out as well. it helped me.

git config --global --unset http.proxy 
git config --global --unset https.proxy

Thank @imsrgadich. it worked for me.

@desktop desktop temporarily blocked ghost Mar 30, 2020
@jlcalderon
Copy link

Hi everybody!

I had the same problem and I solved differently. First, I was getting the error, because I created the Local repo and initialized before I had an online instance of the repo. Then manually, online in my git hub account created the repo to push my local files on it. When I tried to push the local repo into the online I got the error.

Solution:

  1. Remove the origin to clear out the initialization by:
    git remote rm origin

  2. Then try again the command lines:
    git remote add "your link to the repo".git
    git push -u origin master

Hope this help somebody.

@Harshada-github
Copy link

@shiv1490
the command worked with me.
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

Did it work for Ubuntu

@steveward
Copy link
Member

@Harshada-github the proxy configuration command will work for Ubuntu.

@emmanuellekamwa
Copy link

All the solutions you proposed did not work for me. Anything else to propose?

@steveward
Copy link
Member

@emmanuellekamwa are you encountering the could not resolve host error? Are you behind a firewall or proxy server? It would also be helpful to know the specific actions you have already taken to try and resolve the issue.

@emmanuellekamwa
Copy link

@steveward Yes I have that error and I am behind a firewall

@steveward
Copy link
Member

@emmanuellekamwa you may need to reach out to someone who can assist with allowing GitHub Desktop access through your firewall. Unfortunately there isn't much we can do on our end about this error. Are you running any specific antivirus software? Is this a corporate machine?

@ayushshaz
Copy link

It worked for me when I used "service apache2 stop" ;-)

@DTechBloKe
Copy link

Uploading git error .png…
Please anyone can help me out? I've tried all the solutions here non of them worked😢

@DTechBloKe
Copy link

Please anyone can help me out? I've tried all the solutions here non of them worked😢

@DTechBloKe
Copy link

Please anyone can help me out? I've tried all the solutions here non of them worked😢
Uploading git error .png…

1 similar comment
@DTechBloKe
Copy link

Please anyone can help me out? I've tried all the solutions here non of them worked😢
Uploading git error .png…

@steveward
Copy link
Member

@DTechBloKe if you can upload your log file in a comment on this issue that should give some more information about the error you are experiencing.

@BlaCBunJEE
Copy link

worked for me

@manojkumar1919
Copy link

not worked for me

@emmaudeji
Copy link

Tried the following git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 and git config --global --unset http.proxy git config --global --unset https.proxy but none seems to work for me; could it be a possible internet strength isssue?

Check again. This worked for me

git config --global --unset http.proxy

@untilhamza
Copy link

untilhamza commented Oct 5, 2022

Tried everything here and it failed.

This helped me.
git config --local credential.helper

https://www.edureka.co/community/66457/fatal-unable-to-access-could-not-resolve-host-github#:~:text=git%20config%20%2D%2Dlocal%20credential.helper%20%22%22

@arex123
Copy link

arex123 commented Oct 17, 2022

simply try reconnecting to your wifi,
It worked for me,

source:
https://stackoverflow.com/a/34777941/16687503

@KendiJ
Copy link

KendiJ commented Mar 30, 2023

Check this out as well. it helped me.

git config --global --unset http.proxy 
git config --global --unset https.proxy

Thanks, this worked well on my M2

@Kellynjenga
Copy link

How can i solve this fatal: unable to access 'https://github.com/ultrasecurity/Storm-Breaker.git/': Could not resolve host: github.com

@minaTfn
Copy link

minaTfn commented Apr 19, 2023

None of the solutions worked for me. Finally re-connecting my wifi did the trick.

@elias8808
Copy link

It shows me this error because I ran out of internet at home for a few hours. but I thought that SD was completely offline and now I realize that if there is no internet it does not work. Is there a way to fix this in case some other day you were without internet?

@niranjandasMM
Copy link

  1. Try restarting your system and try again all these :

  2. git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

  3. git config --global --unset http.proxy

  4. git clone https://github.com/niranjandasMM/TEST.git

@Naggenda
Copy link

Check this out as well. it helped me.

git config --global --unset http.proxy 
git config --global --unset https.proxy

this worked for me

@SriSomanaath
Copy link

thanks this worked for me
git config --global --unset http.proxy

@Zahid43300
Copy link

None of this worked for me can anyone help me 🥲 i am using kali linux on phone

@masumsoftdev
Copy link

#git config --global --unset http.proxy
#git config --global --unset https.proxy

Upon commands helped me, you can try also

@davik4life
Copy link

I encountered this same issue today for the first time and immediately noticed it had to do with my internet connectivity. I realized my internet router went off, which was the reason for the error. As soon as I went back online, the push command worked.

@alvinChristianto
Copy link

in my case its because windows defender public firewall.

i use wsl2 ubuntu 20 distro, usually i can push and fetch, but after some changes in host windows, wsl2 cant push and fetch. The ping github.com also fail. after some searching for issue, i try disable windows defender public firewall, and then try to do git commands and it works again.

@EduMRX
Copy link

EduMRX commented Jan 2, 2024

Se você está enfrentando problemas de resolução de host no Kali Linux e precisa resolver o problema temporariamente, pode criar um script que ajuste as configurações do arquivo /etc/resolv.conf. Certifique-se de entender que esta é uma solução temporária, e você deve procurar corrigir o problema subjacente com as configurações de rede ou DNS em seu ambiente. Aqui está um exemplo de um script simples que você pode criar:

Crie um script chamado, por exemplo, fix_dns.sh:

**#!/bin/bash

# Backup do arquivo resolv.conf
sudo cp /etc/resolv.conf /etc/resolv.conf.backup

# Substitui as configurações do arquivo resolv.conf
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo "nameserver 8.8.4.4" | sudo tee -a /etc/resolv.conf

# Mensagem informativa
echo "Configurações DNS temporárias aplicadas. Tente novamente."

# Exemplo de comando para clonar o repositório Git após aplicar as configurações
# git clone https://github.com/niranjandasMM/TEST.git/

# Restaure as configurações originais (opcional)
# sudo cp /etc/resolv.conf.backup /etc/resolv.conf**

Certifique-se de tornar o script executável com o comando:

chmod +x fix_dns.sh

Execute o script com:

sudo bash fix_dns.sh

Este script faz backup do arquivo resolv.conf original, substitui temporariamente as configurações com servidores DNS públicos do Google (8.8.8.8 e 8.8.4.4) e exibe uma mensagem informativa. Lembre-se de que isso é uma solução temporária e não corrige o problema subjacente na configuração do seu ambiente.

@Goku9689
Copy link

fix git clone unable resolve hosts name
vi /etc/hosts
in this and localhosts and localdomain like 127.0.0.1. and it's opposite section mention localhosts and localdomain
sudo service networking restart
and start git clone
Uploading Screenshot_20240415-211909.png…

@CodeNKoffee
Copy link

The error message you're seeing,fatal: unable to access 'https://github.com/....': Could not resolve host: github.com, suggests a DNS resolution issue, meaning your computer is unable to find the IP address associated with github.com. This can be due to various reasons such as network connectivity issues, DNS server problems, or local DNS cache issues. Here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Check your Internet connection:
    Ensure that your Mac is connected to the internet. You can try accessing other websites or pinging a well-known site.
ping -c 4 google.com
  1. Flush your DNS cache:
    This can help if the issue is related to a corrupted or outdated DNS cache.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

@def-fun
Copy link

def-fun commented Jul 9, 2024

To anyone who is using git CMD over socks5 proxy:

if your computer failed to access github.com by git or curl command like next:

C:\Users\admin>ping github.com
Ping request could not find host github.com. Please check the name and try again.

C:\Users\admin>curl -v github.com
* Rebuilt URL to: github.com/
* Could not resolve host: github.com
* Closing connection 0
curl: (6) Could not resolve host: github.com

C:\Users\admin>curl -v github.com --proxy socks5://192.168.29.1:1080
* Rebuilt URL to: github.com/
*   Trying 192.168.29.1...
* TCP_NODELAY set
* SOCKS5 communication to github.com:80
* Could not resolve host: github.com
* Closing connection 0
curl: (6) Could not resolve host: github.com

and if you can get 301 redirect over a socks5 proxy:

# `20.205.243.166` is the IP of github.com, you can found it at https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses
# `192.168.29.1:1080` is your socks5 proxy
C:\Users\admin>curl -v 20.205.243.166 --proxy socks5://192.168.29.1:1080
* Rebuilt URL to: 20.205.243.166/
*   Trying 192.168.29.1...
* TCP_NODELAY set
* SOCKS5 communication to 20.205.243.166:80
* SOCKS5 connect to IPv4 20.205.243.166 (locally resolved)
* SOCKS5 request granted.
* Connected to 192.168.29.1 (192.168.29.1) port 1080 (#0)
> GET / HTTP/1.1
> Host: 20.205.243.166
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-Length: 0
< Location: https://20.205.243.166/
<
* Connection #0 to host 192.168.29.1 left intact

it means that your computer failed to resolve DNS but your proxy socks5 works and you can use git over this proxy when configured properly.

using http:// or socks5h:// (not socks5://) will enable your git to access github.com

git config --global http.proxy http://192.168.29.1:8088   # use http proxy
git config --global https.proxy socks5h://192.168.29.1:1080   # or use socks5 proxy
git clone https://github.com/abhinavsingh/proxy.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-info-needed The submitter needs to provide more information about the issue
Projects
None yet
Development

No branches or pull requests