title: Local DynamoDB: Unable to execute HTTP request — Connection refused
body: <p>I run local DynamoDB and an app via <code>docker-compose</code>. Unfortunately I encounter an error when querying DynamoDB from the app:</p>
  
  <pre><code>Unable to execute HTTP request: Connect to dynamodb:80 [dynamodb/172.18.0.2] failed: Connection refused (Connection refused)
  </code></pre>
  
  <p>Here is how the docker-compose looks like:</p>
  
  <pre><code>version: "3"
  services:
    dynamodb:
      image: "dynamodb-local:latest"
      container_name: app-dynamodb
      ports:
        - "80:8000"
    api:
      image: "app-backend:latest"
      container_name: app-api
      ports:
        - "5000:5000"
        - "5100:5100"
      environment:
        - DYNAMO_HOST=dynamodb:80
  </code></pre>
  
  <p>Here is how a Dockerfile for DynamoDB:</p>
  
  <pre><code>FROM openjdk:8-jre
  
  ENV DYNAMODB_VERSION=latest
  
  COPY .aws/ root/.aws/
  COPY setup.sh setup.sh
  COPY setup-stats.sh setup-stats.sh
  
  RUN apt-get update &amp;&amp; \
      apt-get install -y python python-pip &amp;&amp; \
      pip --no-cache-dir install awscli &amp;&amp; \
      apt-get clean all &amp;&amp; \
      curl -O https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_${DYNAMODB_VERSION}.tar.gz &amp;&amp; \
      tar zxvf dynamodb_local_${DYNAMODB_VERSION}.tar.gz &amp;&amp; \
      rm dynamodb_local_${DYNAMODB_VERSION}.tar.gz
  
  EXPOSE 8000
  
  ENTRYPOINT java -Djava.library.path=. -jar DynamoDBLocal.jar --sharedDb -inMemory
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <ol>
  <li>I'm able to connect to dynamoDB JS shell from the host by <a href="http://localhost/shell" rel="nofollow noreferrer">http://localhost/shell</a></li>
  <li>I'm NOT able to connect to dynamoDB from the app container:</li>
  </ol>
  
  <pre><code>wget dynamodb/shell
  Connecting to dynamodb (172.18.0.2:80)
  wget: can't connect to remote host (172.18.0.2): Connection refused
  </code></pre>
  
  <ol start="3">
  <li>The app is written on Scala and uses Scanamo for interaction with DynamoDB</li>
  </ol>