99x / 99x/serverless-dynamodb-local

ECONNREFUSED for sls dynamodb start

Open
#194 27 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
621
Forks
232
PR merge metrics
No merged PRs in 30d

Description

**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**

```js
// package.json
{
// ...
"devDependencies": {
// ...
"dynamodb-local": "^0.0.24",
// ...
"serverless-dynamodb-local": "^0.2.35",
"serverless-offline": "^3.31.3",
// ...
}
}
```

```yml
# 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.
```

Contributor guide

Open the contributing guide

Research direction

Start with the dynamodb:start entry point and the stack-trace locations in node_modules/serverless-dynamodb-local/index.js, then reproduce the command using the provided serverless.yml and package.json configuration. Done means `sls dynamodb start` completes without ECONNREFUSED, the local DynamoDB endpoint responds at port 8000, and table migration succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js
Domain
backend, cli, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.