WSL2のUbutnu18.04 LTSでapt updateするとconnection timed out Could not connectになる


$ sudo apt update
Err:1 https://dl.yarnpkg.com/debian stable InRelease
  Cannot initiate the connection to dl.yarnpkg.com:443 (2606:4700::6812:7e64). - connect (101: Network is unreachable) Cannot initiate the connection to dl.yarnpkg.com:443 (2606:4700::6810:ab63). - connect (101: Network is unreachable) Could not connect to dl.yarnpkg.com:443 (104.16.171.99), connection timed out Could not connect to dl.yarnpkg.com:443 (104.18.126.100), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out
W: Failed to fetch https://dl.yarnpkg.com/debian/dists/stable/InRelease  Cannot initiate the connection to dl.yarnpkg.com:443 (2606:4700::6812:7e64). - connect (101: Network is unreachable) Cannot initiate the connection to dl.yarnpkg.com:443 (2606:4700::6810:ab63). - connect (101: Network is unreachable) Could not connect to dl.yarnpkg.com:443 (104.16.171.99), connection timed out Could not connect to dl.yarnpkg.com:443 (104.18.126.100), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.

結論

入れていたセキュリティ対策ソフトウェアの「Symantec Endpoint Protection」が原因みたい。

Symantec Endpoint Protectionを開いて、[ネットワークとホストのエクスプロイト緩和機能]→[オプション]→[ネットワーク脅威防止を無効にする]をクリックします。

もう一度試してみましょう。

$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1544 kB]
Hit:5 https://dl.yarnpkg.com/debian stable InRelease
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [298 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1884 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1109 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [390 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1718 kB]
Fetched 7195 kB in 25s (291 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

ソフトウェアのインストールやパッケージの更新をする際は一時的にオフにして対処しようと思います。