'ssh: Could not resolve hostname github.com: Temporary failure in name resolution

The repo was cloned using SSH at the start. I had no issues pushing to Github until today. I've been trying to solve this error for a whole day but i still cannot solve this error.. It would be great if anyone can shed some light on this! Thank you :)

2dsnakegame git:(main) git push origin main
ssh: Could not resolve hostname github.com: Temporary failure in name resolution
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
➜  2dsnakegame git:(main) git remote
origin
➜  2dsnakegame git:(main) git remote --v
origin  [email protected]:xxxx/2dsnakegame.git (fetch)
origin  [email protected]:xxxx/2dsnakegame.git (push)


Solution 1:[1]

I had the same situation working on Windows with WSL2. It looks like there was a trouble on the connection to the DNS server, so I basically reset my TCP/IP with the following commands and then git pull/git push worked again.

From University of Wisconsin: Windows 10 TCP/IP Reset: Open the cmd prompt on Windows as an administrator and run the following commands in this order in order to fix your connection problem:

netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
ipconfig /flushdns

Finally, restart your computer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel Staples