Skip to content

How to connect to SQS queue

I have created several SQS queues in the management console.

All the queues have full access permission (Allow – Everybody – All SQS Actions)

I have created necessary credentials and can connect to AWS.

Now I am trying to connect to created queues:

public static List<String> listQueues(AmazonSQS sqs) {
  System.out.println("Listing all queues in your account.n");
  ListQueuesResult queueList = sqs.listQueues();
  List<String> queueUrls = queueList.getQueueUrls();
  for (String queueUrl : queueUrls) {
    System.out.println("  QueueUrl: " + queueUrl);

  return queueUrls;

But nothing is displayed.

At the same time, if I create queue programatically:

public static String createQueue(String queueName, AmazonSQS sqs) {
  System.out.println("Creating a new SQS queue called MyQueue.n");
  CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
  return sqs.createQueue(createQueueRequest).getQueueUrl();

It is listed and I can send and receive messages from it.

BUT I don’t see created queue in Management Console!

What am I doing wrong?

BTW I can connect to queues created from Management Console by URL

If you are playing wih example from Amazon (like me) – keep in mind that BasicAWSCredentials contain only accessKey and secretKey, and region won’t be read from credentials file.

Region is being set up “manually” for AmazonSQSClient:

public static AmazonSQS createSqsClient() {
    AWSCredentials credentials = null;
    try {
        credentials = new ProfileCredentialsProvider().getCredentials();
    } catch (Exception e) {
        throw new AmazonClientException(
                "Cannot load the credentials from the credential profiles file. " +
                        "Please make sure that your credentials file is at the correct " +
                        "location (~/.aws/credentials), and is in valid format.",

    AmazonSQS sqs = new AmazonSQSClient(credentials);
    Region region = Region.getRegion(Regions.US_EAST_2);
    return sqs;



SQS queues are located in specific regions.

  1. Confirm which region your code is creating the region in, then
  2. Ensure you’re looking in that same region in the AWS Management Console.