aaronshaf/dynamodb-admin

Inaccessible host: `localhost'. This service may not be available in the `eu-west-1' region.

mr-py-007 opened this issue · 14 comments

Hi Aaron!

Thank you for your great work.

I want to use your solution to test dynamodb on local but I get this error when I run the command.
AWS_REGION=eu-west-1 AWS_ACCESS_KEY_ID=local AWS_SECRET_ACCESS_KEY=local dynamodb-admin

UnknownEndpoint: Inaccessible host: `localhost'. This service may not be available in the `us-east-1' region.
    at Request.ENOTFOUND_ERROR (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/event_listeners.js:530:46)
    at Request.callListeners (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:688:14)
    at error (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/event_listeners.js:362:22)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/http/node.js:99:9)
    at ClientRequest.emit (events.js:375:28)
    at ClientRequest.emit (domain.js:470:12)
    at Socket.socketErrorListener (_http_client.js:475:9)
    at Socket.emit (events.js:375:28)

I couldn't find the answer in the issues.
Could you please let me know how can I resolve this issue and make it work.
I am on Ubuntu 20.04.

Thanks in advance

rchl commented

Are you sure that you are running a local dynamodb instance?

rchl commented

https://hub.docker.com/r/aaronshaf/dynamodb-admin/ is just for the dynamodb-admin, you still need to have a separate docker container running amazon/dynamodb-local. Have you started that one too? Do you see it running with docker ps (or sudo docker ps) and what ports are exposed for it (check the PORTS column)?

So I have both containers running here

CONTAINER ID   IMAGE                          COMMAND                  CREATED          STATUS          PORTS                                       NAMES
2e2befdafd53   aaronshaf/dynamodb-admin       "docker-entrypoint.s…"   10 seconds ago   Up 9 seconds    0.0.0.0:8001->8001/tcp, :::8001->8001/tcp   engine_dynamodb-admin_1
d3afa74ff4ff   amazon/dynamodb-local:latest   "java -jar DynamoDBL…"   10 seconds ago   Up 10 seconds   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   engine_dynamodb-local_1

But I cannot access the admin http://localhost:8001

I also try to connect dynamodb in python using boto3
But it does not work either

And when I run this command, it does not respond at all
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1

And finally says this

Read timeout on endpoint URL: "http://localhost:8000/"
rchl commented

For aws dynamodb list-tables --endpoint-url http://localhost:8000 I would expect a credentials error but not read timeout. That sounds like there is some bigger issue with communicating with your docker containers. Maybe some sort of firewall or configuration issue. I don't know enough about docker to help but it's likely not an issue specific to this project.

@mr-py-007 Let config DYNAMO_ENDPOINT environment variable in your docker-compose file.

version: '3.7'

services:
  dynamoDB-local:
    image: amazon/dynamodb-local:1.13.6
    ports:
      - '4569:8000'
  dynamo-admin:
    image: aaronshaf/dynamodb-admin
    environment:
      - DYNAMO_ENDPOINT=dynamodb-local:8000
    ports:
      - '8002:8001'
rchl commented

Hope that the last answer helped. Closing.

Hi, Something similar happens to me with node 18 but it works with node 12 and 14.

Also have experienced the same.
I have localstack with a running dynamodb, localstack configured with standard port 4566
dynamodb is accessible using aws cli with '--endpoint-url=http://localhost:4566' option

running:
PORT=8010 DYNAMO_ENDPOINT=http://localhost:4566 AWS_ACCESS_KEY_ID=local AWS_SECRET_ACCESS_KEY=local dynamodb-admin

with dynamodb-admin installed in node v14.17.2 and v16.16.0 the admin UI appears successfully (port 8010)

with dynamodb-admin installed in node v17.2.0 or v18.12.1, the admin fails to connect as shown by op.

same here with the last two comments

If you are using macOS, this is likely related to breaking changes in Node v17 favoring IPv6 over IPv4 depending on the DNS configuration. Try using using 127.0.0.1 instead of localhost as hostname.

See full explanation here: localstack/aws-cdk-local#76 (comment)

gtracy commented

I'm having a similar problem. I'm running the amazon/dynamodb-local image in docker desktop. Then running dynamodb-admin from the CLI.

I'm running version 4.5.0

I've run with node 18.15.0, 16.9.1 and 19.8.1 and all three produce the reported error above when I go to localhost:8001 in my browser. Same result when I substitute 127.0.0.1 for localhost in the browser.

UnknownEndpoint: Inaccessible host: localhost' at port 8000'. This service may not be available in the us-east-2' region.
at Request.ENOTFOUND_ERROR (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/event_listeners.js:611:46)
at Request.callListeners (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/request.js:686:14)
at error (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/event_listeners.js:443:22)
at ClientRequest. (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/http/node.js:99:9)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at Socket.socketErrorListener (node:_http_client:494:9)
at Socket.emit (node:events:513:28)`

I've tried launching dynamodb-local by overriding the host as suggested as a Mac IPV6 issue, but it produces the same result (error).

dynamodb-admin --host 127.0.0.1 --port 8001

This worked when I ran the docker image from the CLI.

docker run -p 8000:8000 amazon/dynamodb-local

This worked when I specified the port (8000) when running the docker image from the desktop interface
This does not make a lot of sense because when I inspect the container logs when I do not specify the port, it indicates that it is defaulting to 8000

environment:
- DYNAMO_ENDPOINT=dynamodb-local:8000

from @lawson-ng comment was the fix for me here. Thanks.