Connection timed out when running commands in macOS
Selasa, 23 April 2024, 2:35 pm0
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.
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 ⁽¹⁾.
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 #NodeJS fetch()
), it will use IPv4 address instead of IPv6.
Done . #webdev
⁽¹⁾ https://discussions.apple.com/thread/251035348
Simplest JS promise tutorial using await / async
24 April 2024
Penutup liburan raya, ngeteh di atas bukit
22 April 2024