Search code examples
node.jsamazon-dynamodbdynamo-local

dynamo-client using local dynamodb client


I'm trying to connect to my dynamodb local using the npm lib dynamo-client. I have the local dynamodb client install and running as per: http://aws.typepad.com/aws/2013/09/dynamodb-local-for-desktop-development.html

However trying to connect to my localhost using:

db = dynamo.createClient('localhost', dbConf.credentials)
db.request('ListTables','', (e,r) -> console.log(e))

gives the following error:

e: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}

Solution

  • Needed to set the port and host in the options:

    dbConf =
      region:
        region: 'localhost'
        host: 'localhost'
        port: 8000
      credentials:
        secretAccessKey: "KEY"
        accessKeyId: "ACCESSKEY"
    
    db = dynamo.createClient(dbConf, dbConf.credentials)