How to Solve LocalStack Always Connecting To LocalHost

I have LocalStack in my local machine for resolving AWS service dependencies. I am trying to test my application which connects to the LocalStack SQS. I have deployed my application as a docker container. The problem is when I am accessing SQS getQueueUrl from my application container, it is giving me localhost as AWS endpoint. But I mentioned my local machine's private IP while setting up Java SQS client.

"exception":"com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to localhost:4566 [localhost/] failed: Connection refused (Connection refused)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException( ~[aws-java-sdk-core-1.11.822.jar:?]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper( ~[aws-java-sdk-core-1.11.822.jar:?]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute( ~[aws-java-sdk-core-1.11.822.jar:?]

The problem is that LocalStack does not override hostname property. So while initializing LocalStack, we need to define HOSTNAME_EXTERNAL field in docker-compose.yml file of LocalStack. It would be somewhat similar to below:

version: '3.0'


    image: localstack/localstack:latest
      - "4566-4599:4566-4599"
      - AWS_DEFAULT_REGION=us-west-2
      - SERVICES=sqs
      - HOSTNAME_EXTERNAL: <hostname/ip of devbox>
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Once you define proper hostname or IP address in HOSTNAME_EXTERNAL field and start LocalStack , that should solve the problem.