Ubuntu WSL2 could not resolve hostname for GIT clone

Viewed 68

I have gitlab local repository and VPN to connect with it. I already installed WSL and it worked well before with clone repository (I've done add ssh pub). After updating kernel from WSL and change to WSL2. I cannot clone repository anymore and it returns:

ssh: Could not resolve hostname gitlab.local.id: Name or service not known

I've done creating /etc/wsl.conf file

[network]
generateResolvConf = true

and /etc/resolv.conf file

nameserver 8.8.8.8

NOTE: I can clone repo through GIT Bash

Restart the WSL, terminal and even reboot laptop. But still cannot clone the repository through SSH. I followed others suggestion but still no luck. Maybe your suggestion may help. many thanks!

1 Answers

It took me almost 3 days to try others workaround to solve it and it's just solved by re-installed the updated distro. I have no clue why origin resolv.conf (generated by WSL) before was gone after updated to WSL2 and suddenly does not resolve any hostname.

After re-install distro and re-added new SSH key to gitlab, WSL generate new resolv.conf file and git back to works again.

UPDATE:

As per request from @Philippe, The new resolve.conf:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.19.144.1

This configuration comes automatically and without wsl.conf at /etc/ directory.

NOTES: Please make sure you working on the right WSL version before you doing something on your distro or you will probably ended up with the same problem above.

Comment form @torek above was right. Git has nothing to do with the problem, but the problem causing git and other servername does not resolve. My problem begun with updating the kernel then change the wsl version in the middle of working on current distro.

Related