Skip to content

How to Fix AWS SQS Message Not Visible

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix AWS SQS Message Not Visible. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Messages are sent to SQS but consumers cannot see them — the visibility timeout hides messages that are being processed, or they went to a dead-letter queue.

Step-by-Step Fix

1. Check queue attributes

aws sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --attribute-names All

Expected output:

{
    "Attributes": {
        "VisibilityTimeout": "30",
        "ApproximateNumberOfMessages": "0",
        "ApproximateNumberOfMessagesNotVisible": "5",
        "RedrivePolicy": "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:123456789012:my-queue-dlq\",\"maxReceiveCount\":\"3\"}"
    }
}

2. Increase visibility timeout for long processing

aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --attributes VisibilityTimeout=120

3. Check the dead-letter queue

aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue-dlq

4. Purge and reprocess messages

aws sqs purge-queue --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue-dlq

5. Adjust maxReceiveCount

{
    "deadLetterTargetArn": "arn:aws:sqs:us-east-1:123456789012:my-queue-dlq",
    "maxReceiveCount": "5"
}

Apply with:

aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-queue --attributes RedrivePolicy='{"deadLetterTargetArn":"arn:aws:sqs:us-east-1:123456789012:my-queue-dlq","maxReceiveCount":"5"}'

Common Mistakes

Mistake Fix
Visibility timeout too short Increase to exceed max processing time
Messages moved to DLQ Check consumer error handling
Consumer not deleting messages Call DeleteMessage after processing
ReceiveMessage wait time too long Reduce WaitTimeSeconds
Queue has too many consumers Use a single consumer or SQS FIFO ordering

Prevention

  • Set visibility timeout to 3x the expected processing time.
  • Monitor ApproximateNumberOfMessagesNotVisible.
  • Use DLQ alarms for failed message processing.
  • Implement idempotent message processing.

Common Mistakes with sqs message

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world AWS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What is SQS visibility timeout?

The visibility timeout is a period during which SQS hides a received message from other consumers. If the message is not deleted within this time, it becomes visible again. |||How do I move messages back from the DLQ to the main queue? Use aws sqs receive-message on the DLQ, then aws sqs send-message to the main queue, and finally aws sqs delete-message on the DLQ. |||Why are messages not visible even though I sent them? Consumers may have already received and not deleted them (not visible due to visibility timeout), or they may have been moved to the dead-letter queue after exceeding maxReceiveCount.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro