aaronshaf/dynamodb-admin

UnknownEndpoint: Inaccessible host: `localhost' at port `4566'. This service may not be available in the `us-west-2' region.

ankushbbbr opened this issue · 5 comments

I am trying to use dynamodb-admin to view dynamoDB running in my localstack docker.
I am running
DYNAMO_ENDPOINT=http://localhost:4566 AWS_REGION=us-west-2 AWS_ACCESS_KEY_ID=test-access-key AWS_SECRET_ACCESS_KEY=test-secret-key dynamodb-admin
and http://localhost:8001/ gives error -
UnknownEndpoint: Inaccessible host: `localhost' at port `4566'. This service may not be available in the `us-west-2' region. at Request.ENOTFOUND_ERROR (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/event_listeners.js:529: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:361:22) at ClientRequest.<anonymous> (/usr/local/lib/node_modules/dynamodb-admin/node_modules/aws-sdk/lib/http/node.js:99:9) at ClientRequest.emit (node:events:520:28) at ClientRequest.emit (node:domain:475:12) at Socket.socketErrorListener (node:_http_client:442:9) at Socket.emit (node:events:520:28)

I have verified using aws-cli that the dynamoDB instance is available at this port in my local.
aws dynamodb list-tables --endpoint-url http://localhost:4566

rchl commented

If aws command is working then I would suspect that it uses different credentials. Maybe check in ~/.aws/config and/or ~/.aws/credentials and see if there is a default profile defined and with what settings.

Also check if the aws command still works after temporarily renaming the ~/.aws directory to something else.

@rchl I have verified that aws-cli is using the same credentials.

$ cat ~/.aws/config
[default]
region = us-west-2

$ cat ~/.aws/credentials
[default]
aws_access_key_id = test-access-key
aws_secret_access_key = test-secret-key

Command used to run dynamodb-admin - DYNAMO_ENDPOINT=http://localhost:4566 AWS_REGION=us-west-2 AWS_ACCESS_KEY_ID=test-access-key AWS_SECRET_ACCESS_KEY=test-secret-key dynamodb-admin

After renaming ~/.aws directory , aws commands do not work.

jcjp commented

I'm having the same issue running with globally installed on npm or using the docker image. @ankushbbbr have you fixed your issue? I tried renaming .aws to aws still produces this error but I can still run aws-cli but doesn't find my credentials.

Okay I actually fixed mine, I used the docker image standalone and then have that point to the dynamodb container. Then on my app or service I point my dynamodb endpoint with the same config with my docker-compose file.

So for example on my compose file here is my endpoint: dynamodb-local:8000 that endpoint will also be the same with your app or service you are running outside docker. Here is a good reference to read: unknownendpoint-inaccessible-host-localhost-when-trying-to-connect-to-local

I came here to post a similar issue. I am running dynamodb with localstack, but using dynamodb-admin as a global npm command.

Setting DYNAMODB_ENDPOINT to http://127.0.0.1:4566 or http://0.0.0.0:4566 will work.

I didn't change the endpoint to docker container endpoint, but it just started working for me now. Not sure what was the issue.