1

I have a problem that I do not understand. With node 18.13.0, I am not able to use Dynamodb locally.

I always get this error: "message": "UnknownEndpoint: Inaccessible host: localhost' at port 8005'. This service may not be available in the `localhost' region.", "type": 0

But with node 16 I have no problem. Here is all the information I can give you, I am on mac (m1) on Ventura 13.1 (also on windows 11).

The serveless version:

  • Framework Core: 3.27.0 (local) 3.27.0 (global)
  • Plugin: 6.2.3
  • SDK: 4.3.2

Here is my serverless.yml:

service: hydradis-planning-delivery
provider:
  name: aws
functions:
  - '${file(routes.yml)}'
plugins:
  - serverless-plugin-typescript
  - serverless-offline
  - serverless-dynamodb-local
custom:
  dynamodb:
    start:
      port: 8005
  serverless-offline:
    httpPort: 3005
    lambdaPort: 3015

Here is my connection:

var dynamoDbCreation = new AWS.DynamoDB({
region: 'localhost',
endpoint: ('http://localhost:8005')
});

Can you help me?

4
  • Did you start DynamoDB Local? Does netstat, or equivalent, show it listening on port 8005? Commented Jan 28, 2023 at 17:28
  • Yes DynamoDB run in local Commented Jan 28, 2023 at 17:58
  • 1
    AWS Lambda node.18x runtime does not use the AWS SDK 2.0 by default. So the DynamoDB code probably wron there. You have 2 option, install the 2.0 aws sdk. Or rewrite the code to support 3.0. docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html Commented Jan 29, 2023 at 10:00
  • I don't know why, but yesterday there was a response that gave the answer. If I replace the localhost in the region field with 127.0.0.1 it works. Thanks anyway for the info. Commented Jan 29, 2023 at 20:32

1 Answer 1

2

You should not use literal string localhost as region but rather the endpoint:

var dynamoDbCreation = new AWS.DynamoDB({
region: 'http://127.0.0.1:8005',
endpoint: ('http://localhost:8005')
});
Sign up to request clarification or add additional context in comments.

1 Comment

in my case it was the endpoint that I needed to change from "localhost" to 127.0.0.1 for example: new AWS.DynamoDB({ region: "localhost"; endpoint: "127.0.0.1:8000"; // instead of localhost:8000"; })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.