Tonton MyTV dilengkapi intisari rancangan pada smart TV bermula RM4.99 sebulan. Selanjutnya →

Connection timed out when running commands in macOS

Selasa, 23 April 2024, 2:35 pm0

F52FE925-A5B4-4A8D-AE3F-3ADC6F4663BF.jpeg
My Mac mini still run on 10.15 (Catalina), as a comparison, latest macOS is version 14 (Sonoma).

I stored some cron job on this Mac which require a connection to remote website. After left the computer running for several days, suddenly the cron job failed with ‘connection timed out’ error.

Previously I solved this issue by restarting the computer, but that just temporary, after a few days the issue occur again & it’s not practical if I’m away from home.

176D19AC-D19A-4645-B388-3E71B42E20DB.jpeg
Today I found out the cause of the issue after trying to run a simple wget command.

Notice that the first attempt failed with error ‘network is unreachable’ & www.google.com.my is resolved to an IPv6 address. But the second attempt, it succeed when using IPv4 address.

So I lookup on the ‘net on how to force macOS to use IPv4 address when trying to connect to remote server, and found this forum thread ⁽¹⁾.

95C79C78-891A-4495-9C74-EF2DE1835950.jpeg
Settings to use IPv6 only on local network.

Open System Preferences > Network > select Wi-Fi > Advanced > TCP/IP tab > Configure IPv6, choose Link-local only.

What this does is when we’re running command to connect to remote website (e.g wget, youtube-dl or fetch()), it will use IPv4 address instead of IPv6.

Done 😎.

⁽¹⁾ https://discussions.apple.com/thread/251035348

Komentar (0):

FB: https://www.facebook.com/100810608155424/posts/1104267664073478/

Tulis komen: