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.

Karma + Node.js 17: can't connect to karma server. There is no server listening on port 9876

See original GitHub issue

When running under Node 17, running karma reports:

 can't connect to karma server. There is no server listening on port 9876 

Switching back to Node 16 seems to “fix” the issue.

See also: https://youtrack.jetbrains.com/issue/WEB-53632

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
devoto13commented, May 10, 2022

https://github.com/nodejs/node/issues/40702 seems to be the culprit. Node 17 changed the DNS resolution, so now it resolves localhost according to the OS settings instead of IPv4 first. The Karma server only listens on IPv4 address (0.0.0.0) by default, but the requests are sent to localhost and localhost is resolved into IPv6 address (::) in Node 17+. So the run request is unable to reach the Karma server.

I’ll think what’s the best way to make it work out of the box. In the meantime you can address the issue by setting listenAddress to :: either in config or using LISTEN_ADDR environment variable.

1reaction
cherniavskiicommented, Jun 2, 2022

Hey @devoto13 Thanks for looking into this.

Indeed, I just realised that the root cause of the issue is that I use VPN (NordVPN to be specific). Without it, the server starts just fine, so I guess VPN is messing with my network configuration.

Anyway, I’ve changed karma net-utils.js code locally to omit host - and it works both with VPN and without it. For now I can use listenAddress: 'localhost' as a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Karma + Node.js 17: can't connect to karma server. There is ...
Karma + Node.js 17: can't connect to karma server. There is no server listening on port 9876. Relates to 1. Relates to 1...
Read more >
How to fix "There is no server listening on port 9876" error ...
Now simply launch karma by using the start command with the config file as an input karma start path/to/tests/karma.conf.js.
Read more >
How to fix “There is no server listening on port 9876” error ...
I am running the following: PS D:\app> karma run. It shows the error: [2013-11-29 17:39:54.297] [DEBUG] config - Loading config D:\app\karma.conf.js There ......
Read more >
How to fix "There is no server listening on port ... - Blogarama
It shows the error: [2013-11-29 17:39:54.297] [DEBUG] config - Loading config D:\app\karma.conf.js There is no server listening on port 9876.
Read more >
Angular-Karma-Test-Explorer/Bugs - Gitter
[3:00:17 PM] INFO: Listening to AngularReporter events on port 9879 ... not finding the tests, must be an issue with the karma.conf.js but...
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