Skip to content

discord.shard Failed to connect for shard_id: 0. Retrying... #10202

Open
@emelchenkoe

Description

@emelchenkoe

Summary

this error will probably always happen when it tries to connect

Reproduction Steps

i've only ran one python script with discord.py in it, but it will probably happen for any other discord.py script

all you need to do is just do
python3 discordBot.py
easy.

Minimal Reproducible Code

Expected Results

2025-06-07 20:39:57 INFO discord.client logging in using static token
and then a success

Actual Results

2025-06-07 20:39:57 INFO discord.client logging in using static token 2025-06-07 20:42:33 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
and it keeps retrying and retrying and retrying...

Intents

haven't checked

System Information

`- Python v3.11.2-final

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

is this enough?
`2025-06-07 20:39:57 INFO discord.client logging in using static token
2025-06-07 20:42:33 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1263, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 723, in _connect_and_send_request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 622, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1189, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1561, in _create_direct_connection
raise last_exc
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1530, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1245, in _wrap_create_connection
async with ceil_timeout(
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in aexit
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/discord/shard.py", line 477, in launch_shard
ws = await asyncio.wait_for(coro, timeout=self.shard_connect_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/gateway.py", line 375, in from_client
socket = await client.http.ws_connect(str(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/http.py", line 554, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 1059, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 768, in _request
resp = await handler(req)
^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 727, in _connect_and_send_request
raise ConnectionTimeoutError(
aiohttp.client_exceptions.ConnectionTimeoutError: Connection timeout to host wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream
2025-06-07 20:45:13 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1263, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 723, in _connect_and_send_request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 622, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1189, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1561, in _create_direct_connection
raise last_exc
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1530, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1245, in _wrap_create_connection
async with ceil_timeout(
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in aexit
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/discord/shard.py", line 477, in launch_shard
ws = await asyncio.wait_for(coro, timeout=self.shard_connect_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/gateway.py", line 375, in from_client
socket = await client.http.ws_connect(str(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/http.py", line 554, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 1059, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 768, in _request
resp = await handler(req)
^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 727, in _connect_and_send_request
raise ConnectionTimeoutError(
aiohttp.client_exceptions.ConnectionTimeoutError: Connection timeout to host wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream
2025-06-07 20:47:53 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1263, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 723, in _connect_and_send_request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 622, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1189, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1561, in _create_direct_connection
raise last_exc
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1530, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1245, in _wrap_create_connection
async with ceil_timeout(
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in aexit
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/discord/shard.py", line 477, in launch_shard
ws = await asyncio.wait_for(coro, timeout=self.shard_connect_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/gateway.py", line 375, in from_client
socket = await client.http.ws_connect(str(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/http.py", line 554, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 1059, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 768, in _request
resp = await handler(req)
^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 727, in _connect_and_send_request
raise ConnectionTimeoutError(
aiohttp.client_exceptions.ConnectionTimeoutError: Connection timeout to host wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream
2025-06-07 20:50:33 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1263, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 723, in _connect_and_send_request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 622, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1189, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1561, in _create_direct_connection
raise last_exc
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1530, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1245, in _wrap_create_connection
async with ceil_timeout(
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in aexit
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/discord/shard.py", line 477, in launch_shard
ws = await asyncio.wait_for(coro, timeout=self.shard_connect_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/gateway.py", line 375, in from_client
socket = await client.http.ws_connect(str(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/http.py", line 554, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 1059, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 768, in _request
resp = await handler(req)
^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 727, in _connect_and_send_request
raise ConnectionTimeoutError(
aiohttp.client_exceptions.ConnectionTimeoutError: Connection timeout to host wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream
2025-06-07 20:53:13 ERROR discord.shard Failed to connect for shard_id: 0. Retrying...
Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1263, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 723, in _connect_and_send_request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 622, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1189, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1561, in _create_direct_connection
raise last_exc
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1530, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1245, in _wrap_create_connection
async with ceil_timeout(
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in aexit
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/idfk/.local/lib/python3.11/site-packages/discord/shard.py", line 477, in launch_shard
ws = await asyncio.wait_for(coro, timeout=self.shard_connect_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/gateway.py", line 375, in from_client
socket = await client.http.ws_connect(str(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/discord/http.py", line 554, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 1059, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 768, in _request
resp = await handler(req)
^^^^^^^^^^^^^^^^^^
File "/home/idfk/.local/lib/python3.11/site-packages/aiohttp/client.py", line 727, in _connect_and_send_request
raise ConnectionTimeoutError(
aiohttp.client_exceptions.ConnectionTimeoutError: Connection timeout to host wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream`

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions