Most Baileys problems fall into a small set of categories: connection handling, authentication state, message retry configuration, and media. The sections below cover the most common issues and their fixes.Documentation Index
Fetch the complete documentation index at: https://whiskeysockets-docs-jids-socket-config-ptbr.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Common issues
Connection keeps dropping / reconnecting
Connection keeps dropping / reconnecting
Baileys does not automatically reconnect after a connection is closed — that is intentional. You must handle reconnection yourself in the Check the
connection.update event.The key is to check DisconnectReason.loggedOut before retrying. A 401 status code means the user actively logged out and reconnecting will not help — you need a fresh QR code. Any other error is safe to retry:DisconnectReason enum for all possible status codes and their meanings.QR code not appearing or keeps refreshing
QR code not appearing or keeps refreshing
If the QR code never appears, the most likely cause is that valid credentials already exist in your auth state. When Baileys finds existing credentials on startup, it tries to reconnect silently without generating a QR.To force a new QR code, delete your auth state folder (for example,
auth_info_baileys/) and restart. Baileys will then start fresh and print a new QR.If you expect a QR but the socket connects immediately, add a log in connection.update to inspect the full update object:printQRInTerminal is marked as deprecated in SocketConfig and may not work in newer versions. If you need QR output, listen for the 'qr' property in connection.update and render it yourself using a package like qrcode-terminal.Messages failing to send ('this message can take a while')
Messages failing to send ('this message can take a while')
WhatsApp’s retry system requires your application to return the original message when a delivery attempt fails. Without this, Baileys cannot retry and the sender sees the “this message can take a while” warning.Implement
getMessage in your SocketConfig to fetch a message from your store by its key:getMessageFromStore is your responsibility — it should look up the message by key.id in whatever storage layer you use (in-memory store, database, etc.).For a complete retry setup, also provide msgRetryCounterCache:Poll votes not decrypting
Poll votes not decrypting
Poll votes are encrypted and arrive as updates in the If
messages.update event, not as new messages. To decrypt them you need two things:getMessageimplemented inSocketConfig(see above) — Baileys needs the original poll message to decrypt the vote- The
getAggregateVotesInPollMessageutility
getMessage returns undefined, the vote will be silently dropped. Make sure your store correctly indexes messages by their full key.Audio messages not playing on some devices
Audio messages not playing on some devices
WhatsApp requires audio to be in Ogg format with the Opus codec. Files in other formats will fail to play on some clients, particularly on iOS.Convert your audio with The required flags are:
ffmpeg before sending:codec: libopus— Ogg/Opus container-ac 1— mono channel (one channel)-avoid_negative_ts make_zero— fix negative timestamps
Group messages failing or being slow
Group messages failing or being slow
Sending to a group requires Baileys to fetch the group’s participant list to build the encryption envelope. If you do not cache this metadata, Baileys makes a live request to WhatsApp for every message — which is slow and can trigger rate limits.Set
cachedGroupMetadata in your SocketConfig and keep the cache warm by listening to group events:Getting logged out of all devices
Getting logged out of all devices
WhatsApp can log you out of all linked devices if it detects malformed chat state updates. This is most commonly triggered by calling
chatModify with incorrect data.Session expired — need to re-authenticate
Session expired — need to re-authenticate
If your credentials have expired or become invalid, Baileys will emit a
connection.update with a DisconnectReason.loggedOut (status 401) close reason. At that point you must start a fresh session:Delete the auth state folder
Remove the folder where you stored credentials (for example,
auth_info_baileys/). This forces Baileys to start a new authentication flow.Restart and scan a new QR
Restart your application. Baileys will generate a new QR code for you to scan.
Media not downloading (404 errors)
Media not downloading (404 errors)
WhatsApp automatically expires media from its servers after a period of time. Once the media URL expires, you will receive a When downloading media with
404 when trying to download it.To recover expired media, request a re-upload from another linked device that still has the file:downloadMediaMessage, pass reuploadRequest so Baileys can automatically handle the re-upload if the original URL has expired:Enable full debug logging
When you cannot identify the root cause from the symptoms alone, enabledebug-level logging to see every raw WebSocket frame that Baileys sends and receives:
tag, attrs, and content of each frame. Look for unexpected frames or error tags (such as 'failure' or 'stream:error') that indicate what WhatsApp is objecting to.
For more on interpreting these frames, see Extend Baileys with custom functionality.
Get support
If you are stuck on an issue that is not covered here, the community Discord is the best place to ask:Baileys Discord
Join the Baileys Discord server for community support, bug reports, and announcements.