Skip to content

How do I troubleshoot the "QueueDoesNotExist" error when I make API calls to my Amazon SQS queue?

4 minute read
0

I want to resolve the "QueueDoesNotExist" error that appears when I make API calls to my Amazon Simple Queue Service (Amazon SQS) queue.

Short description

Amazon SQS API operations, such as GetQueueAttributes, SendMessage, and DeleteMessage can cause the "QueueDoesNotExist" error. For more information, see Errors.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, verify that you're using the most recent AWS CLI version.

Check that the queue URL is correct

Check that the queue URL that's provided in the request is correct and contains no typos.

Important: If the destination queue is First-In-First-Out (FIFO), then you must add the .fifo suffix to the queue URL.

Set the correct AWS Region

You receive the "QueueDoesNotExist" error when you make a request to the incorrect Region. The SDK and AWS CLI don't retrieve the destination Region from the queue URL. Instead, the client configuration sets the Region.

Before you call an API, set the correct Region on the Amazon SQS client. Review the Amazon SQS client configuration to confirm that you configured the correct Region on the client. When you don't configure a Region on the client, the SDK or AWS CLI chooses the Region from the configuration file or the environment variable. When the SDK doesn't find a Region in the configuration file, then the SDK sets the Region to us-east-1 by default.

For more information, see Configuration and credential file settings.

If AWS CloudTrail supports the failed operation, then check all Regions in the AWS account for the failed Amazon SQS operation. If the operation fails in one Region, then check if you configured that Region correctly on the client.

Activate the debug log on the SDK or the AWS CLI to check the Region of the request. Debug logs show the destination host for the request. For example, if the log contains "Host: sqs.us-east-1.amazonaws.com", then the Region is us-east-1.

These are additional debug log resources:

Note: To validate the Region, account, or queue name, verify that you log the full queue details.

Check for a recently deleted queue

You might receive a "QueueDoesNotExist" error when a queue was recently deleted. Identify the timestamp of the failed operation. Then, check CloudTrail for PurgeQueue operations at the time of the error. The message deletion process takes up to 60 seconds.

The error can also occur when the queue is part of an AWS CloudFormation or other deployment stack, and CloudFormation or the deployment process deletes the queue. Stack updates or deletions can delete and recreate the queue. If you call the operation to the queue at the time of deletion, then the request might fail. Check your CloudTrail logs for DeleteQueue operations at the time of the error.

Specify the destination queue account number when you use GetQueueUrl

For API operations, the SDK or AWS CLI take the destination queue account number from the queue URL. However, the GetQueueUrl operation doesn't provide a queue's account in the request, so the request is made against the caller account by default.

If the request is intended for a cross-account queue, then you must specify the destination queue account number as the operation's QueueOwnerAWSAccountId parameter.

Delete messages that are moved to a DLQ within the timeout window

For standard SQS queues that are configured with a dead-letter queue (DLQ), Amazon SQS moves messages to the DLQ after retries. After the message enters the DLQ, the "QueueDoesNotExist" error can occur when you perform a DeleteMessage operation with an old ReceiptHandle from the main queue. You must delete messages within the configured VisibilityTimeout window.

Verify that the requester has the required IAM permissions

You receive the following error message when the requester's AWS Identity and Access Management (IAM) user or role lacks the required permissions:

"The specified queue does not exist or you do not have access to it."

Use the GetCallerIdentity operation to confirm that the IAM entity has the required permissions.

Example GetCallerIdentity operation in Boto3 Python:

import boto3

sts = boto3.client('sts')

print(sts.get_caller_identity())

For example Amazon SQS policies, see Basic examples of Amazon SQS policies.

For more information on Amazon SQS permissions, see How do I grant access to an Amazon SQS queue?

Troubleshoot with Support

If the preceding troubleshooting actions don't resolve your issue, then contact AWS Support. Include the RequestId and timestamp with timezone of the failed operations.