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.

Error: listen EADDRINUSE :::8080

See original GitHub issue

Hi everyone 😃 Quick question, how can I add more tests that need to connect to DB similar to the model/post.spec.js?

I keep getting a

 1. Uncaught Exception
   Error: listen EADDRINUSE :::8080
    Object.exports._errnoException (util.js:1026:11)
    exports._exceptionWithHostPort (util.js:1049:20)

every time I try to add a new spec file that has the code below in it.

test.beforeEach('connect to database', t => {
  connectDB(t, () => {
    console.log('connected to DB for account tests');
  });
});

test.afterEach.always(t => {
  dropDB(t);
});

Any suggestions/ideas? Thank you 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
drewbrendcommented, Jan 25, 2019

@panvourtsis I know this is over a year late, but I just ran into this issue and solved it. The tests are running in parallel and both trying to spin up a DB on the same port. You need to run them serially by adding the --serial flag to the test command in package.json.

"test": "cross-env NODE_ENV=test PORT=8080 MONGO_URL=mongodb://localhost:27017/test-results node_modules/.bin/nyc node node_modules/ava/cli.js --serial",

Hopefully that helps someone else.

1reaction
panvourtsiscommented, Dec 4, 2017

@Fallenstedt yes i know what it means. The thing is that when you got more than one test in place for the models this happens in whatever port you define. It just starting the next test without closing the usage of the port. Tried 8080, 4350, 6565 etc etc always the same

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Error: listen EADDRINUSE while using NodeJS?
EADDRINUSE means that the port(which we try to listen in node application) is already being used.
Read more >
Error listen EADDRINUSE while using nodejs - Edureka
Hello @kartik,. EADDRINUSE means that the port number which listen() tries to bind the server to is already in use. So, in your...
Read more >
How to kill server when seeing “EADDRINUSE: address ...
When this EADDRINUSE issue has already happened, in order to resolve it, you need to kill the process manually. In order to do...
Read more >
How to find and terminate a Windows Processes by Port
Learn how to locate the Windows Process occupying a specific port and terminate it when you get an "error listen eaddrinuse: address already...
Read more >
listen EADDRINUSE :::8080 · Issue #995 · MichMich/MagicMirror
Hi.. i have a little problem. but it works. node serveronly/ Starting MagicMirror: v2.1.2 Loading config ... Loading module helpers .
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