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

4 minute read
0

I made API calls to my Amazon Simple Queue Service (Amazon SQS) queue and received a “QueueDoesNotExist” error.

Resolution

Some Amazon SQS API calls, such as GetQueueAttributes, SendMessage, and DeleteMessage can cause the QueueDoesNotExist error. To troubleshoot this error, follow these steps.

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 type is First-In-First-Out (FIFO), then you must append the .fifo suffix to the queue URL.

Set the correct Region

You get the QueueDoesNotExist error when a request is made to the incorrect AWS Region. The SDK and AWS Command Line Interface (AWS CLI) don't get the destination Region from the queue URL. Instead, the client configuration sets the Region.

Before you make an API call, 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, then 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 AWS Region and Configuration and credential file settings.

If AWS CloudTrail supports the failed API call, then check all Regions in the AWS account for the failed Amazon SQS operation. This helps to determine whether the Region is the cause of the issue.

You can also 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: Host: sqs.us-east-1.amazonaws.com.

These are additional debug log resources:

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

Check for a recently deleted queue

You might receive a QueueDoesNotExist error when a queue is recently deleted. Identify the timestamp of the failed API call, and then check CloudTrail for any 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 the queue is deleted. Stack updates or deletions can cause the queue to be deleted and recreated. If you make the API call to the queue at the time of deletion, then the request can fail. Check CloudTrail for any DeleteQueue operations at the time of the error.

Specify the destination queue account number when you use GetQueueUrl

For API calls, the SDK or AWS CLI usually takes the destination queue account number from the queue URL. However, the GetQueueUrl API call 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 API call 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), messages are moved to the DLQ after retries. After the message is moved to 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.

Make sure that the requester has the required IAM permissions

If the requesting AWS Identity and Access Management (IAM) user or role doesn't have the required permissions, then you might receive the following error: "The specified queue does not exist or you do not have access to it."

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

Example GetCallerIdentity API call 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 What permissions do I need to access an Amazon SQS queue?

Troubleshoot with AWS Support

If the preceding troubleshooting steps don't resolve your issue, the contact AWS Support. Include the RequestId and timestamp with timezone of the failed API calls.

AWS OFFICIAL
AWS OFFICIALUpdated a year ago