Skip to content

Docker container connection refused #828

@stevenh

Description

@stevenh

Inspector Version

  • 0.16.8

Describe the bug
When using the published docker command from the readme connecting to the container doesn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Run the docker container
docker run --rm --network host -p 6274:6274 -p 6277:6277 ghcr.io/modelcontextprotocol/inspector:latest
  1. Try to connect
curl http://localhost:6274
  1. Connection fails:
curl: (7) Failed to connect to localhost port 6274 after 0 ms: Couldn't connect to server

Same happens if you click the link to load in a browser.

This site can’t be reached
localhost refused to connect.
Try:

Checking the connection
[Checking the proxy and the firewall](chrome-error://chromewebdata/#buttons)
ERR_CONNECTION_REFUSED

Expected behavior
A clear and concise description of what you expected to happen.
The browser should connect.

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Environment (please complete the following information):

  • OS: MacOS 26.0 (kernel: 25.0.0)
  • Browser: Chrome Version 140.0.7339.208 (Official Build) (arm64) and curl

Additional context
Also tried without host networking enabled.

Also CTRL+C doesn't correctly stop the container either.

docker info
Client:
 Version:    28.4.0
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.9.11
    Path:     /Users/steve/.docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.28.0-desktop.1
    Path:     /Users/steve/.docker/cli-plugins/docker-buildx
  cloud: Docker Cloud (Docker Inc.)
    Version:  v0.4.27
    Path:     /Users/steve/.docker/cli-plugins/docker-cloud
  compose: Docker Compose (Docker Inc.)
    Version:  v2.39.2-desktop.1
    Path:     /Users/steve/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.42
    Path:     /Users/steve/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.2.0
    Path:     /Users/steve/.docker/cli-plugins/docker-desktop
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /Users/steve/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /Users/steve/.docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.18.0
    Path:     /Users/steve/.docker/cli-plugins/docker-mcp
  model: Docker Model Runner (Docker Inc.)
    Version:  v0.1.40
    Path:     /Users/steve/.docker/cli-plugins/docker-model
  offload: Docker Offload (Docker Inc.)
    Version:  v0.4.27
    Path:     /Users/steve/.docker/cli-plugins/docker-offload
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/steve/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.18.3
    Path:     /Users/steve/.docker/cli-plugins/docker-scout
WARNING: Plugin "/Users/steve/.docker/cli-plugins/docker-dev" is not valid: failed to fetch metadata: fork/exec /Users/steve/.docker/cli-plugins/docker-dev: no such file or directory

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 33
 Server Version: 28.4.0
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Discovered Devices:
  cdi: docker.com/gpu=webgpu
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.10.14-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 11
 Total Memory: 11.67GiB
 Name: docker-desktop
 ID: a85f5bbd-f12a-40de-b03a-482b11704019
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/steve/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Testing with a basic nginx container works as expected:

docker run --rm --name nginx-test -p 8080:80 nginx:alpine
curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
...

Looks like this is a IPv6 / host networking issues.

After enabling host networking on docker desktop -> Settings -> Resources -> Network -> Enable host networking (ticked) and restarting docker the default command works.

There must be something about how the server is being started that is causing the issue as running a simple node server also works as expected:

docker run --rm -it -p 8080:3000 node:24-slim sh -c   "npm install -g serve && echo 'hello world' > index.html && serve -p 3000"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions