Need help: Application unable to connect to Localstack sqs

Hi,

I have an application which connects to sqs. I was able to create the sqs properly and below is the output

aws sqs list-queues --endpoint-url http://localhost:4566

 "QueueUrls": [
        "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/xyz-syncOrgList",
        "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/xyz-recreateFilesEvent",
        "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/xyz-updateOrgTable"
    ]

But the issue arises when I launch my app from using docker compose then it throws below error.

Caused by: com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to sqs.us-east-1.localhost.localstack.cloud:4566 [sqs.us-east-1.localhost.localstack.cloud/127.0.0.1] failed: Connection refused (Connection refused)

xyz-aaaaaa-backend  | Caused by: org.apache.http.conn.HttpHostConnectException: Connect to sqs.us-east-1.localhost.localstack.cloud:4566 [sqs.us-east-1.localhost.localstack.cloud/127.0.0.1] failed: Connection refused (Connection refused)
xyz-aaaaaa-backend  |    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156) ~[httpclient-4.5.13.jar!/:4.5.13]

here is the complete error: gist:0cf9220bfb835ed4214ba7cd06315fcc ยท GitHub

here is the code inside my docker-compose.yml

version: "3.8"

services:

  xyz-aaaaaa-backend:
    container_name: "xyz-aaaaaa-backend"
    image: xyz-aaaaaa-backend/xyz-aaaaaa-backend:1249
    environment:
      - SPRING_PROFILE=localstack
      - AWS_ACCESS_KEY_ID=dummy
      - AWS_SECRET_ACCESS_KEY=dummy
      - ENABLE_DATADOG=false
      - LOCALSTACK_URL=localstack 
      - AWS_REGION=us-east-1
    ports:
      - "8080:8080"
    networks:
      default:

networks:
  default:
    name: backend
    external: true

here is my application-localstack.yml file:

amazon:
  region: us-east-1
  dynamodb:
    endpoint:
      url: http://${LOCALSTACK_URL:localhost}:4566
  sqs:
    endpoint:
      url: http://${LOCALSTACK_URL:localhost}:4566
      #url: http://sqs.us-east-1.localhost.localstack.cloud:4566
    output-recreate-xml-files-event-queue: xyz-recreateFilesEvent
    output-avxUpdateOrgPatientsTable: xyz-updateOrgTable
    input-sync-org-list-from-AVX-queue: xyz-syncOrgList
  s3:
    endpoint:
      url: http://s3.localhost.localstack.cloud:4566

Could you please help me how I can fix this issue.

Hi @MummanaSubramanya,

Please have a look at the default docker-compose.yml for LocalStack to set it up and visit our docs for the Network troubleshooting | Docs (localstack.cloud).