question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ECONNREFUSED for sls dynamodb start

See original GitHub issue

Actual Behaviour

Trying to start the database with sls dynamodb start it hangs for a while then gives error:

connect ECONNREFUSED 127.0.0.1:8000

I was able to get it running earlier, but after restarting the computer it stopped working.

Restarting the computer, changing the port and clearing reinstalling node_modules doesn’t change anything.

There is nothing running on that port, and there are no java processes already running to suggest the database is already alive. http://localhost:8000/shell does not run and the serverless functions timeout trying to connect to the database.

Expected Behaviour

Run sls dynamodb start and it runs.

Steps to reproduce it

// package.json
{
  // ...
  "devDependencies": {
    // ...
    "dynamodb-local": "^0.0.24",
    // ...
    "serverless-dynamodb-local": "^0.2.35",
    "serverless-offline": "^3.31.3",
    // ...
  }
}
# serverless.yml
custom:
  # ...
  dynamodb:
    stages:
      - dev
    start:
      migrate: true
      inMemory: true
      noStart: true

plugins:
  - serverless-step-functions
  - serverless-plugin-typescript
  - serverless-dynamodb-local
  - serverless-step-functions-offline
  - serverless-offline

# ...

resources:
  Resources:
    ExampleTable:
      Type: AWS::DynamoDB::Table
      Properties:
        AttributeDefinitions:
          - AttributeName: foo
            AttributeType: S
        KeySchema:
          - AttributeName: foo
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: ${self:provider.environment.DYNAMODB_TABLE}

LogCat for the issue

$ SLS_DEBUG=* yarn sls dynamodb start
yarn run v1.12.3
$ serverless dynamodb start
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command invoke
Serverless: Load command invoke:stepf
Serverless: Load command dynamodb
Serverless: Load command dynamodb:migrate
Serverless: Load command dynamodb:seed
Serverless: Load command dynamodb:start
Serverless: Load command dynamodb:noStart
Serverless: Load command dynamodb:remove
Serverless: Load command dynamodb:install
Serverless: Load command step-functions-offline
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke dynamodb:start
Serverless: DynamoDB - Error -

  Networking Error ---------------------------------------

    connect ECONNREFUSED 127.0.0.1:8000

        For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

NetworkingError: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1121:14)
From previous event:
    at ServerlessDynamodbLocal.createTable (/Users/foo/bar/node_modules/serverless-dynamodb-local/index.js:290:16)
    at BbPromise.each (/Users/foo/bar/node_modules/serverless-dynamodb-local/index.js:169:55)
From previous event:
    at ServerlessDynamodbLocal.migrateHandler (/Users/foo/bar/node_modules/serverless-dynamodb-local/index.js:169:26)
    at BbPromise.resolve.then (/Users/foo/bar/node_modules/serverless-dynamodb-local/index.js:219:45)
From previous event:
    at ServerlessDynamodbLocal.startHandler (/Users/foo/bar/node_modules/serverless-dynamodb-local/index.js:219:10)
    at BbPromise.reduce (/Users/foo/bar/node_modules/serverless/lib/classes/PluginManager.js:391:55)
From previous event:
    at PluginManager.invoke (/Users/foo/bar/node_modules/serverless/lib/classes/PluginManager.js:391:22)
    at PluginManager.run (/Users/foo/bar/node_modules/serverless/lib/classes/PluginManager.js:422:17)
    at variables.populateService.then.then (/Users/foo/bar/node_modules/serverless/lib/Serverless.js:157:33)
    at processImmediate (timers.js:632:19)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Serverless.run (/Users/foo/bar/node_modules/serverless/lib/Serverless.js:144:8)
    at serverless.init.then (/Users/foo/bar/node_modules/serverless/bin/serverless:44:28)

  Get Support --------------------------------------------
    Docs:          docs.serverless.com
    Bugs:          github.com/serverless/serverless/issues
    Issues:        forum.serverless.com

  Your Environment Information -----------------------------
    OS:                     darwin
    Node Version:           11.3.0
    Serverless Version:     1.34.1

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:27

github_iconTop GitHub Comments

5reactions
jasonlimantorocommented, Jun 20, 2019

Any news on this? I have similar issues whereby ^C doesn’t terminate the dynamodb-local process, although is said otherwise in the documentation. It only stops the serverless offline process.

However, once I do

 kill $(lsof -t -i :8000)

to kill all process runing on that port, and then run

sls offline start

for the next time around, the terminal hangs in this stage:

....
Dynamodb Local Started, Visit: http://localhost:8000/shell
....

and then it finally displays the error

Networking Error ---------------------------------------

  connect ECONNREFUSED 127.0.0.1:8000

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

NetworkingError: connect ECONNREFUSED 127.0.0.1:8000

before terminating the prompt.

However even after the prompt is terminated, i.e.

error Command failed with exit code 1.

http://localhost:8000/shell/ works, which is very very weird and sad.

Restarting the whole process would yield the exact same behavior 😦 And yes, even after running the command sls dynamodb remove, the exact same behavior is still happening.

Any help would be appreciated 😃

5reactions
SamCBcommented, Dec 17, 2018

Ok. Figured out the fix. Had the .dynamodb directory lying around.

rm -r .dynamodb

And I was able to start up the database. Though is this expected behavior? Why did it cause this particular error and how do I stop it in the future without manually deleting things?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js connect ECONNREFUSED 127.0.0.1:8000 ...
I have read that the error means starting the DynamoDB local server failed. But I have no idea why since it doesn't give...
Read more >
[Solved] Unable to start DynamoDB Local process - Dynobase
sls dynamodb install --localPath ./bin. After you have installed the Local DynamoDB, you can start it by executing the following command: sls offline...
Read more >
unable to initialize main class com.amazonaws.services ...
Part of AWS Collective 1 Hey guys I'm trying to run Dynamodb with serverless locally executing the following command: sls dynamodb start --migrate...
Read more >
How To Solve Dynamodb Networking Error From ... - ADocLib
Actual Behaviour Trying to start the database with sls dynamodb start it hangs for dynamodb:start Serverless: DynamoDB - Error - Networking Error I...
Read more >
99xt - Bountysource
yarn add -D serverless-dynamodb-local sls dynamodb install ... i run sls dynamodb start - I populate the database, I stop dynamodb local and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found