Python function to check if a host is reachable Apr 12, 2020 (Tested on MacOS 10.15.3) import os def host_is_reachable(host: str) -> bool: return True if os.system(f"ping -t 1 -o {host}") == 0 else False Note: this is not safe if the host parameter will be coming from an untrusted user.