Skip to content

Improve connection refused error message #543

@nabuskey

Description

@nabuskey

Describe the bug

Currently, proxy server prints Connection refused. Is the MCP server running? under two circumstances:

  1. Error message contains Error POSTing to endpoint (HTTP 404) OR
  2. Error message contains ECONNREFUSED.

The term "Connection Refused" usually means it could not make connections at all.
I think it makes sense to print the error message in case of ECONNREFUSED because that's how node defines it.

I don't think it makes sense to print that when the connection was successful but a 404 was returned by the server.

It took me some time to figure out why it kept saying "Connection Refused" when the server was clearly running.

See:

function onServerError(error: Error) {
if (
(error?.message &&
error.message.includes("Error POSTing to endpoint (HTTP 404)")) ||
(error?.cause && JSON.stringify(error.cause).includes("ECONNREFUSED"))
) {
console.error("Connection refused. Is the MCP server running?");
} else {
console.error("Error from MCP server:", error);
}
}

To Reproduce

Steps to reproduce the behavior:

  1. Have a MCP running.
  2. Open Inspector. Confirm it's accessible at /mcp.
  3. Change endpoint to /mcp1.

Expected behavior

In case the server returns a 404, either print the error as-is or handle it differently if required.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions