Issue
I have installed Ubuntu 20.04 LTS on WSL.
I'm trying to run the following command:
curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
It fails with error:
curl: (6) Could not resolve host: developer.mozilla.org
I have tried something else, and it worked, e.g.
$ curl https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
Here's some details:
$ nslookup developer.mozilla.org
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
developer.mozilla.org canonical name = d1avawhiqh9uo1.cloudfront.net.
Name: d1avawhiqh9uo1.cloudfront.net
Address: 52.84.112.124
Name: d1avawhiqh9uo1.cloudfront.net
Address: 52.84.112.61
Name: d1avawhiqh9uo1.cloudfront.net
Address: 52.84.112.82
Name: d1avawhiqh9uo1.cloudfront.net
Address: 52.84.112.105
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:8e00:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:9c00:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:a000:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:d800:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:f600:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:200:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:1c00:13:e62f:2040:93a1
Name: d1avawhiqh9uo1.cloudfront.net
Address: 2600:9000:203c:4e00:13:e62f:2040:93a1
Please help to understand the problem.
Solution
This worked for me: https://github.com/microsoft/WSL/issues/4731#issuecomment-562935992
This is happening to me after my pc goes to sleep for long hours. Shutting down wsl2 (wsl.exe --shutdown) and open it again solves the problem until the next time the pc goes to sleep again for long hours.
Answered By - Adrian Answer Checked By - Candace Johnson (WPSolving Volunteer)