diff --git a/wait_for_it/wait_for_it.py b/wait_for_it/wait_for_it.py
index b9f7549..95e856a 100644
--- a/wait_for_it/wait_for_it.py
+++ b/wait_for_it/wait_for_it.py
@@ -54,7 +54,7 @@ async def _wait_until_available(host, port):
             if sys.version_info[:2] >= (3, 7):
                 await writer.wait_closed()
             break
-        except (socket.gaierror, ConnectionError):
+        except (socket.gaierror, ConnectionError, OSError, TypeError):
             pass
         await asyncio.sleep(1)
 

Exception when connecting to an unreachable local host.
```console
wait-for-it -s localhost:1234
```
```
[*] Waiting 15 seconds for localhost:1234
Traceback (most recent call last):
  File "/usr/local/bin/wait-for-it", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 98, in cli
    _connect_all_serial(service, timeout)
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 183, in _connect_all_serial
    connect(service, timeout)
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 191, in connect
    _asyncio_run(_wait_until_available_and_report(reporter, host, port))
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 24, in _asyncio_run
    return asyncio.run(*args, **kvargs)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 51, in _wait_until_available_and_report
    await _wait_until_available(host, port)
  File "/usr/local/lib/python3.8/site-packages/wait_for_it/wait_for_it.py", line 39, in _wait_until_available
    _reader, writer = await asyncio.open_connection(host, port)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/streams.py", line 52, in open_connection
    transport, _ = await loop.create_connection(
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1033, in create_connection
    raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 1234), [Errno 61] Connect call failed ('::1', 1234, 0, 0)
```
diff --git a/wait_for_it/test_wait_for_it.py b/wait_for_it/test_wait_for_it.py
index 42e0e72..2baa4bc 100644
--- a/wait_for_it/test_wait_for_it.py
+++ b/wait_for_it/test_wait_for_it.py
@@ -51,10 +51,10 @@ def _start_server_thread():
     return server
 
 
-def _occupy_free_tcp_port():
+def _occupy_free_tcp_port(host):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    sock.bind(("127.0.0.1", _ANY_FREE_PORT))
-    host, port = sock.getsockname()
+    sock.bind((host, _ANY_FREE_PORT))
+    _, port = sock.getsockname()
     return host, port, sock
 
 
@@ -100,9 +100,18 @@ class CliTest(TestCase):
         finally:
             server.stop()
 
-    @parameterized.expand([("parallel", ["-p"], 2), ("serial", [], 1)])
-    def test_service_unavailable(self, _label, extra_argv, expected_report_count):
-        host, port, sock = _occupy_free_tcp_port()
+    @parameterized.expand(
+        [
+            ("parallel", ["-p"], 2, "127.0.0.1"),
+            ("parallel", ["-p"], 2, "0.0.0.0"),
+            ("parallel", ["-p"], 2, "localhost"),
+            ("serial", [], 1, "127.0.0.1"),
+            ("serial", [], 1, "0.0.0.0"),
+            ("serial", [], 1, "localhost"),
+        ]
+    )
+    def test_service_unavailable(self, _label, extra_argv, expected_report_count, host):
+        _, port, sock = _occupy_free_tcp_port(host)
         try:
             result = self._runner.invoke(
                 cli,

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///croot/attrs_1668696182826/work
black==23.3.0
bleach==6.0.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
click==8.1.8
coverage==7.2.7
cryptography==44.0.2
docutils==0.20.1
execnet==2.0.2
flake8==5.0.4
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
idna==3.10
importlib-metadata==4.2.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
jaraco.classes==3.2.3
jeepney==0.9.0
keyring==23.9.3
markdown-it-py==2.2.0
mccabe==0.7.0
mdurl==0.1.2
more-itertools==9.1.0
mypy-extensions==1.0.0
packaging @ file:///croot/packaging_1671697413597/work
parameterized==0.9.0
pathspec==0.11.2
pkginfo==1.10.0
platformdirs==4.0.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.17.2
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.8.1
SecretStorage==3.3.3
six==1.17.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
twine==4.0.2
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
-e git+https://github.com/clarketm/wait-for-it.git@6d21debe387243e646be8f61f780a360b8e11429#egg=wait_for_it
webencodings==0.5.1
zipp @ file:///croot/zipp_1672387121353/work

name: wait-for-it
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - black==23.3.0
      - bleach==6.0.0
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - coverage==7.2.7
      - cryptography==44.0.2
      - docutils==0.20.1
      - execnet==2.0.2
      - flake8==5.0.4
      - idna==3.10
      - importlib-metadata==4.2.0
      - jaraco-classes==3.2.3
      - jeepney==0.9.0
      - keyring==23.9.3
      - markdown-it-py==2.2.0
      - mccabe==0.7.0
      - mdurl==0.1.2
      - more-itertools==9.1.0
      - mypy-extensions==1.0.0
      - parameterized==0.9.0
      - pathspec==0.11.2
      - pkginfo==1.10.0
      - platformdirs==4.0.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - readme-renderer==37.3
      - requests==2.31.0
      - requests-toolbelt==1.0.0
      - rfc3986==2.0.0
      - rich==13.8.1
      - secretstorage==3.3.3
      - six==1.17.0
      - twine==4.0.2
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - webencodings==0.5.1
prefix: /opt/conda/envs/wait-for-it

wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_2_parallel wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_5_serial
wait_for_it/test_wait_for_it.py::CliTest::test_command_invocation_forwards_exit_code_0 wait_for_it/test_wait_for_it.py::CliTest::test_command_invocation_forwards_exit_code_1 wait_for_it/test_wait_for_it.py::CliTest::test_help wait_for_it/test_wait_for_it.py::CliTest::test_service_available_0_parallel wait_for_it/test_wait_for_it.py::CliTest::test_service_available_1_serial wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_0_parallel wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_1_parallel wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_3_serial wait_for_it/test_wait_for_it.py::CliTest::test_service_unavailable_4_serial wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_rejected_0__1_1234 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_rejected_1_domain_ext_1 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_rejected_2_domain_ext_65536 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_rejected_3_domain_ext_1_2 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_0__1_1234 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_1_domain_ext wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_2_domain_ext_0 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_3_domain_ext_1 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_4_domain_ext_65535 wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_5_http_domain_ext wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_6_http_domain_ext_path_ wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_7_https_domain_ext wait_for_it/test_wait_for_it.py::DetermineHostAndPortForTest::test_supported_8_https_domain_ext_path_
wait_for_it/wait_for_it.py
wait_for_it/wait_for_it.py