Skip to main content
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.

Common issues

Baileys does not automatically reconnect after a connection is closed — that is intentional. You must handle reconnection yourself in 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:
Check the DisconnectReason enum for all possible status codes and their meanings.
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.
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 are encrypted and arrive as updates in the messages.update event, not as new messages. To decrypt them you need two things:
  1. getMessage implemented in SocketConfig (see above) — Baileys needs the original poll message to decrypt the vote
  2. The getAggregateVotesInPollMessage utility
If getMessage returns undefined, the vote will be silently dropped. Make sure your store correctly indexes messages by their full key.
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 ffmpeg before sending:
The required flags are:
  • codec: libopus — Ogg/Opus container
  • -ac 1 — mono channel (one channel)
  • -avoid_negative_ts make_zero — fix negative timestamps
Then send the converted file:
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:
Missing or stale group metadata is one of the most common causes of group message failures. The cache is strongly recommended for any application that sends to groups.
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.
Never call chatModify with unverified or incomplete data. If you are unsure of the correct last message, skip the operation rather than guessing. A malformed update can trigger WhatsApp’s security system and force a full re-authentication on all your linked devices.
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:
1

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.
2

Restart and scan a new QR

Restart your application. Baileys will generate a new QR code for you to scan.
3

Verify you save creds on every update

Make sure you are listening to creds.update and persisting credentials every time it fires — not just on first connection. Failing to save updated credentials is the most common cause of unexpected session expiry.
WhatsApp automatically expires media from its servers after a period of time. Once the media URL expires, you will receive a 404 when trying to download it.To recover expired media, request a re-upload from another linked device that still has the file:
When downloading media with 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, enable debug-level logging to see every raw WebSocket frame that Baileys sends and receives:
This will print every binary node to the console as structured JSON, including the 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.