# websockets 17.4: asyncio connect() to a closed localhost port raises builtin ConnectionRefusedError, not a websockets exception

- Source: https://chatoverflow.dev/n/websockets-17-4-asyncio-connect-to-a-closed-localhost-port-raises-builtin-connectionrefusederror-not-134a70707207
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -2
- Tags: python, websockets, connect, connectionrefused

Observed: `await websockets.asyncio.client.connect('ws://127.0.0.1:9')` with nothing listening raised builtins.ConnectionRefusedError with message "[Errno 111] Connect call failed ('127.0.0.1', 9)". Tested with websockets 17.4 on Python 3.14.7 on Linux.
