9

I cannot connect to DynamoDB that is running local using cli.

aws dynamodb list-tables --endpoint-url http://localhost:8000

Could not connect to the endpoint URL: "http://localhost:8000/"

This doesn't work either: aws dynamodb list-tables --region local Could not connect to the endpoint URL: "http://localhost:8000/"

I tried using a different port and that didn't help. I disabled all proxies too. I am able to connect to DynamoDB using an application like this so I know it's not a dynamodb issue: aws dynamodb list-tables --endpoint-url http://dynamodb.us-west-2.amazonaws.com --region us-west-2

{ "TableNames": [ "Music" ] }

NoSQLKnowHow
  • 4,449
  • 23
  • 35
Noura
  • 149
  • 1
  • 2
  • 9
  • How are you starting up the DynamoDb running locally? – CheeseFerret Jul 16 '20 at 16:31
  • 1
    I followed the instructions here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html. I aso get this in my logs: Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path: [.] – Noura Jul 16 '20 at 16:52
  • which java version are you using ? – saranjeet singh Jul 16 '20 at 16:56
  • java version "14.0.1" 2020-04-14 – Noura Jul 16 '20 at 17:16
  • 1
    Actually "Could not connect to the endpoint URL" may happen in various cases, even if no service is listening on host:port (e.g. dynamodb not running or running on different port), so definitely need to run with `aws dynamodb` with `--debug` to see the actual error. – RAM237 Jan 19 '21 at 13:45

2 Answers2

3

When you run

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

command from your terminal make sure output will be like below and no service will be running on port 8000:

Initializing DynamoDB Local with the following configuration:
Port:   8000
InMemory:       false
DbPath: null
SharedDb:       true
shouldDelayTransientStatuses:   false
CorsParams:     *

It means, this service running successfully on port 8000.

DynamoDB requires any/fake credentials to work.

AWS Access Key ID: "fakeMyKeyId"
AWS Secret Access Key: "fakeSecretAccessKey"

then try below command to list tables.

aws dynamodb list-tables --endpoint-url http://localhost:8000
saranjeet singh
  • 868
  • 6
  • 17
  • The output after running java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb is just like above. I have configured my credentials using cli configure and provided the key and secret key. Running aws dynamodb list-tables --endpoint-url http://localhost:8000 fails – Noura Jul 16 '20 at 17:13
  • Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path: [./DynamoDBLocal_lib] – Noura Jul 16 '20 at 17:19
  • have a look here: https://github.com/aws-samples/aws-dynamodb-examples/issues/22 – saranjeet singh Jul 16 '20 at 17:25
0

The error in your logs is the key here Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path: [.]

This means that the specific dependency cannot be located.

The link that Saranjeet provided has a few solutions. I prefer this solution for testing:

First, you need to download the zip file from offcial website. Unzip the file, copy all the *.dll, *.dylib, *.so to a folder under your project root. Say, src/test/resources/libs.
Then, add the code

System.setProperty("sqlite4java.library.path", "src/test/resources/libs/");
before you initialize a local instance of AmazonDynamoDB.
CheeseFerret
  • 597
  • 11
  • 21