Search code examples
node.jsamazon-web-servicesamazon-dynamodbserverless

Unable to use Dynamodb locally with Node 18.13.0


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?


Solution

  • 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')
    });