Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ankushbbbr opened this issue Apr 12, 2022 · 5 comments

Comments

@ankushbbbr
Copy link

ankushbbbr commented Apr 12, 2022

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
Copy link
Collaborator

rchl commented Apr 12, 2022

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.

@ankushbbbr
Copy link
Author

@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
Copy link

jcjp commented May 24, 2022

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

@fancycade
Copy link

fancycade commented Aug 9, 2022

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.

@ankushbbbr
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants