Learning center

Why is my SQS dead-letter queue filling up?

An SQS message moves to the dead-letter queue once it is received more times than the source queue's maxReceiveCount without being deleted. A slow trickle usually means a few poison messages; a sudden step means a consumer outage pushed many good messages over the limit. Compare the dead-letter queue's growth with the consumer's error timeline before you redrive anything.

Two causes, one alarm#

A source queue with a redrive policy names a dead-letter queue (deadLetterTargetArn) and a maxReceiveCount. When a message's receive count exceeds maxReceiveCount, SQS moves it to the dead-letter queue. The alarm is usually on the dead-letter queue's ApproximateNumberOfMessagesVisible, the metric AWS recommends for watching a DLQ. GetQueueAttributes · SQS metrics and DLQs

Two different incidents raise it:

  • Poison messages. A few messages fail every time they are processed: a payload the consumer cannot parse, a record that violates a constraint, a message in a format the running consumer does not know. Everything else is processed normally.
  • A consumer outage. The consumer receives messages but fails on all of them for a while, typically because a dependency it calls is down. Every message received in that window collects receives and, once past the limit, moves to the dead-letter queue even though nothing is wrong with it.

A consumer that is fully stopped does not fill the dead-letter queue. Receive counts only grow when something receives, so a stopped consumer shows up as a backlog on the source queue instead: why SQS messages pile up.

Why they look alike#

Both put messages in the same queue, and SQS keeps the message, not the error that sent it there. Its age metric hides the timing too: ApproximateAgeOfOldestMessage on the DLQ reflects when a message was moved, not when it was sent. NumberOfMessagesSent on the DLQ does not count messages moved there by a redrive policy, so it stays flat during both incidents. SQS metrics · Dead-letter queues

What differs is the shape and the timing. Poison messages arrive at roughly the rate the bad messages are produced, and the source queue keeps deleting almost everything it receives. An outage arrives as a step: at the earliest, maxReceiveCount visibility timeouts after the consumer started failing, many messages move within minutes, and the source queue's deletes drop to near zero over the same window.

Read without moving anything#

Find the queues involved and the limits. On the dead-letter queue, list-dead-letter-source-queues lists the source queues that point at it. On each source queue, RedrivePolicy holds the target and maxReceiveCount, and VisibilityTimeout sets how fast receives accumulate. list-dead-letter-source-queues · get-queue-attributes

aws sqs list-dead-letter-source-queues \
  --profile PROFILE --region REGION --queue-url DLQ_URL --output json --no-cli-pager

aws sqs get-queue-attributes \
  --profile PROFILE --region REGION --queue-url SOURCE_QUEUE_URL \
  --attribute-names RedrivePolicy VisibilityTimeout MessageRetentionPeriod \
  --output json --no-cli-pager

Then put three series on one timeline in five-minute periods: the DLQ's ApproximateNumberOfMessagesVisible (Maximum), the source queue's NumberOfMessagesDeleted and NumberOfMessagesReceived (Sum), and the consumer's error count from its own logs or metrics. get-metric-statistics

aws cloudwatch get-metric-statistics \
  --profile PROFILE --region REGION \
  --namespace AWS/SQS --metric-name ApproximateNumberOfMessagesVisible \
  --dimensions Name=QueueName,Value=DLQ_NAME \
  --start-time 2026-11-23T12:00:00Z --end-time 2026-11-23T16:00:00Z \
  --period 300 --statistics Maximum --output table --no-cli-pager

Finally, group the consumer's failure logs by error type and by a message key. Thousands of messages failing with one error inside one window point to an outage. One error on the same few keys, spread over days, points to poison.

Looking inside the dead-letter queue changes it#

Reading a message body means calling ReceiveMessage on the DLQ. That changes state: each returned message becomes invisible for the DLQ's visibility timeout and its receive count goes up. If you do it, take a small sample, set --visibility-timeout short and ask for DeadLetterQueueSourceArn and ApproximateReceiveCount with --message-system-attribute-names. Do not delete what you read unless you mean to discard it. receive-message · ReceiveMessage

# Changes state: hides these messages for 30 seconds and increments their receive count.
aws sqs receive-message \
  --profile PROFILE --region REGION --queue-url DLQ_URL \
  --max-number-of-messages 5 --visibility-timeout 30 \
  --message-system-attribute-names SentTimestamp ApproximateReceiveCount DeadLetterQueueSourceArn \
  --output json --no-cli-pager

Decide what the DLQ is telling you#

DLQ growthSource deletesConsumer errorsPoints to
Slow, steadyNormalOne error, few keysPoison messages
Step after an error spikeNear zero in the windowOne error dominatesConsumer outage
Step right after a releaseNear zero for one message typeParse or schema errorsRelease and message format

The third row is a poison case caused by a deploy. If the consumer was rolled back and now meets messages the newer producer sent, read new-format messages after a rollback. If a producer started sending a new format before consumers understood it, read changing a message so both consumers handle it.

Redrive after you know which#

Dead-letter queue redrive moves messages back to their source queue or to another queue of the same type, with an optional maximum rate. It changes state, so start it only once the cause is fixed. list-message-move-tasks is the read-only view of a running or past redrive: Status, ApproximateNumberOfMessagesMoved, ApproximateNumberOfMessagesToMove and FailureReason. Redrive cannot filter or modify messages, and redriven messages get a new message ID and enqueue time. Configure DLQ redrive · start-message-move-task · list-message-move-tasks

After an outage, redriving everything is usually right, at a rate the consumer and its dependency can absorb. With poison messages, a redrive only sends them round again; fix the consumer or handle those messages separately first.

A worked example: two full dead-letter queues#

This example is illustrative. The fictional orders service consumes orders-events in account 111122223333, with maxReceiveCount 5 and a 60-second visibility timeout. Its DLQ is orders-events-dlq.

In the first incident, the DLQ holds 38 messages, gained over two days at a few per hour. Source deletes match sends. The consumer logs one error for all 38, a constraint violation on a currency field, and all 38 come from one partner integration. These are poison messages. Redriving them changes nothing; the consumer or the partner's payload needs fixing.

In the second incident, the DLQ goes from 0 to 21,400 between 14:07 and 14:20 UTC. The consumer logged connection timeouts to the orders database from 14:01 to 14:18, and source deletes were near zero over the same minutes. Five receives at 60 seconds each put the first moves at about 14:06. The messages are fine; the database was down. Once the database is healthy, redrive at a limited rate.

Limits#

maxReceiveCount counts receives, not failures: a consumer that receives a message and lets it expire for any reason, including a slow dependency, uses up a receive. A message that outlives its visibility timeout while still being processed also counts: duplicate processing from visibility timeouts. For standard queues, a message's expiry in the DLQ is based on its original enqueue time, so set the DLQ's retention longer than the source queue's or old messages can expire before you look. Dead-letter queues

The metrics show when messages moved, not which consumer attempt failed. For that you need the consumer's logs. More on the path to each dependency is in diagnosing runtime dependency failures.

Questions#

What does maxReceiveCount mean for an SQS dead-letter queue?

It is the number of times a consumer can receive a message from the source queue before SQS moves it to the dead-letter queue. A value of 1 sends a message there after a single failed attempt.

Can I read DLQ messages without changing them?

No. Reading a body requires a receive, which hides the message for the visibility timeout and increments its receive count. Sample a few with a short visibility timeout and leave them undeleted.

Will a redrive fix poison messages?

No. Redrive moves them back unchanged, and they fail again and return to the dead-letter queue after another maxReceiveCount receives.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading