# Buggy code
def get_external_ip_from_centralized_source(
    log: Logger = IP_DETECTION_LOGGER,
) -> Union[str, None]:
    """Use hardcoded URL to determine the external IP address of this host."""
    endpoint = "https://ifconfig.me/"
    ip = __request(url=endpoint)
    if ip:
        log.info(
            f"Fetched external IP address ({ip}) from centralized source ({endpoint})."
        )
    return ip


# Traceback (ConnectionRefusedError)
Verbose mode is enabled
Authenticating Ursula
Qualifying worker
✓ Worker is bonded to 0x559A0408aAf3beAb55E80Bd5E2ea83D233f43F7d
✓ Worker is funded with 0.378943746597798709 ETH
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/nucypher/characters/lawful.py", line 1466, in __attempt
teacher = cls.from_seed_and_stake_info(seed_uri=teacher_uri,
File "/usr/lib/python3.8/site-packages/nucypher/characters/lawful.py", line 1507, in from_seed_and_stake_info
certificate = network_middleware.get_certificate(host=host, port=port)
File "/usr/lib/python3.8/site-packages/nucypher/network/middleware.py", line 176, in get_certificate
seednode_certificate = ssl.get_server_certificate(addr=(host, port))
File "/usr/lib/python3.8/ssl.py", line 1483, in get_server_certificate
with  create_connection(addr) as sock:
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/nucypher", line 8, in <module>
sys.exit(nucypher_cli())
File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/nucypher/cli/options.py", line 169, in wrapper
return func(**kwargs)
File "/usr/lib/python3.8/site-packages/nucypher/cli/options.py", line 169, in wrapper
return func(**kwargs)
File "/usr/lib/python3.8/site-packages/nucypher/cli/options.py", line 169, in wrapper
return func(**kwargs)
File "/usr/lib/python3.8/site-packages/nucypher/cli/commands/ursula.py", line 390, in run
perform_startup_ip_check(emitter=emitter, ursula=URSULA, force=force)
File "/usr/lib/python3.8/site-packages/nucypher/cli/actions/configure.py", line 157, in perform_startup_ip_check
external_ip = determine_external_ip_address(network=ursula.domain, known_nodes=ursula.known_nodes)
File "/usr/lib/python3.8/site-packages/nucypher/utilities/networking.py", line 172, in determine_external_ip_address
rest_host = get_external_ip_from_default_teacher(network=network)
File "/usr/lib/python3.8/site-packages/nucypher/utilities/networking.py", line 105, in get_external_ip_from_default_teacher
teacher = Ursula.from_teacher_uri(teacher_uri=top_teacher_url,
File "/usr/lib/python3.8/site-packages/nucypher/characters/lawful.py", line 1481, in from_teacher_uri
return __attempt()
File "/usr/lib/python3.8/site-packages/nucypher/characters/lawful.py", line 1477, in __attempt
return __attempt(attempt=attempt + 1)
File "/usr/lib/python3.8/site-packages/nucypher/characters/lawful.py", line 1463, in __attempt
raise ConnectionRefusedError("Host {} Refused Connection".format(teacher_uri))
ConnectionRefusedError: Host https://mainnet.nucypher.network:9151 Refused Connection

# Fixed code
def get_external_ip_from_centralized_source(
    log: Logger = IP_DETECTION_LOGGER,
) -> Union[str, None]:
    """Use hardcoded URL to determine the external IP address of this host."""
    ip = _request(url=CENTRALIZED_IP_ORACLE_URL)
    if ip:
        log.info(
            f"Fetched external IP address ({ip}) from centralized source ({CENTRALIZED_IP_ORACLE_URL})."
        )
    return ip