Discord error 4005: Already authenticated
Last verified against Discord Developer Docs - Opcodes and status codes
You sent more than one identify payload. Don't do that!What error 4005 means
Your client sent a second Identify (op 2) on a connection that was already identified. A gateway connection authenticates once; if you need a new session you open a new socket. Sending Identify again on the live socket is treated as a protocol violation and the connection is closed.
In libraries this typically comes from calling login() / run() / start() twice, for example once at module load and once in a main function, or from a hot-reload setup that re-executes the bot entry point without tearing down the old client. Custom clients produce it when their reconnect logic sends Identify on the existing socket instead of opening a new one, or when a resume failure handler falls through into an identify path while the socket is still open.
What it looks like
// WebSocket close frame
code: 4005
reason: "Already authenticated."Why it happens
- client.login() / bot.run() called more than once on the same client instance
- Hot reload or test harness re-running the startup code without destroying the client
- Custom client sending Identify after a successful Resume on the same socket
- Reconnect logic that identifies without closing the old WebSocket
How to fix Discord error 4005
- 1Search for duplicate login/run calls and ensure the entry point runs exactly once
- 2On hot reload, destroy the client (client.destroy() / bot.close()) before constructing a new one
- 3In custom clients, open a new socket for any new Identify; never re-identify on a socket that has completed the handshake
- 4Track a per-connection identified flag and refuse to send a second Identify
How to stop it recurring
Construct and start the client in one place guarded against re-entry. For development, use a process manager that restarts the whole process on change rather than re-requiring modules inside a live process.
Double-identify is almost always a lifecycle bug in your process management rather than in protocol code. One client instance, one entry point, explicit teardown on reload. The identify concurrency and session budgets a duplicate login also drains are on the Discord limits page; sending before identifying is the mirror-image bug, 4003.
Official reference: Discord Developer Docs - Opcodes and status codes. See all Discord error codes or the Discord limits and quotas.
Related codes
Error 4005 - quick answers
What does Discord error 4005 mean?
Your client sent a second Identify (op 2) on a connection that was already identified. A gateway connection authenticates once; if you need a new session you open a new socket. Sending Identify again on the live socket is treated as a protocol violation and the connection is closed.
How do I fix Discord error 4005?
1. Search for duplicate login/run calls and ensure the entry point runs exactly once 2. On hot reload, destroy the client (client.destroy() / bot.close()) before constructing a new one 3. In custom clients, open a new socket for any new Identify; never re-identify on a socket that has completed the handshake 4. Track a per-connection identified flag and refuse to send a second Identify
Should I retry after error 4005?
No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.
Stop debugging Discord by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.