Skip to content

Improve error message for address already in use #22936

Closed
@ericandrewlewis

Description

@ericandrewlewis

Hello! This is my first issue on this repository, thanks for Node and all that y'all do!

In my class, sometimes students will start an Express server on the same port of one running in another terminal tab.

They get an error message like this:

15:20 $ node server.js 
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::5678
    at Server.setupListenHandle [as _listen2] (net.js:1336:14)
    at listenInCluster (net.js:1384:12)
    at Server.listen (net.js:1471:7)
    at Function.listen (/Users/ericlewis/Desktop/js-express-and-sequelize-lab/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/Users/ericlewis/Desktop/js-express-and-sequelize-lab/server.js:11:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1363:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:266:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)

I wonder if we could improve this error message because it's a bit ambiguous what the actual problem is to newcomers.

I saw that this already came up in the Express issue tracker, where the suggestion was to change the error message in Node itself. The suggestion there was to add this context:

EADDRINUSE: http://localhost:3000 is already in use

Metadata

Metadata

Assignees

No one assigned

    Labels

    errorsIssues and PRs related to JavaScript errors originated in Node.js core.netIssues and PRs related to the net subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions