Connection timed out when running commands in macOS

Selasa, 23 April 2024, 2:35 pm0

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.

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’ & 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 ⁽¹⁾.

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 😎.


Komentar (0):


Tulis komen: