amazon-web-servicesdockerlocalstack

localstack trying to connect to localhost:4566 when we explicitly have the url set to 4576


My team is trying to get a local setup for our project. We are running the same docker-compose file with image localstack/localstack:0.8.10. We are running the same shell script. Our script looks like this...

awslocal sns subscribe \
    --topic-arn arn:aws:sns:us-east-1:123456789012:cx-clientcomm-traffic-controller-sent \
    --protocol sqs \
    --notification-endpoint http://localhost:4576/queue/cx-clientcomm-request-processor-queue

For whatever reason, two of the developers are getting this error. Could not connect to the endpoint URL: http://localhost:4566 for the SQS.

I know this port is used for the latest versions of localstack, but they're running the same image as us.

Any ideas??


Solution

  • It is a known issue. You need to add the following properties to the docker-compose localstack image:

    So your original docker-compose will look like:

    localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack}"
    image: localstack/localstack
    hostname: localstack
    networks:
      - anynet
    ports:
      - "4566:4566"
    environment:
      - SERVICES=sqs,sns
      - DEBUG=1
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
      - HOSTNAME_EXTERNAL=localstack
    volumes:
      - ./data:/tmp/localstack
      - "/var/run/docker.sock:/var/run/docker.sock"
    

    This will not work if you put localhost to any of these properties! You need to choose another name. I put localstack as hostname and HOSTNAME_EXTERNAL, and it worked for me.