Skip to content

[Bug]: MCP: 0.0.0.0 is incorrectly translated to loopback for http mode, breaking non-loopback use #42952

Closed

Description

@yeasah

Version

v1.63.0

Steps to reproduce

run the MCP server with --host 0.0.0.0, i.e.:

node /app/cli.js --headless --browser chromium --no-sandbox --port 8931 --host 0.0.0.0

This is the actual docker configuration recommended by the playwright-mcp documentation, and it doesn't work (the service binds to 127.0.0.1):

docker run -d -i --rm --init --pull=always \
  --entrypoint node \
  --name playwright \
  -p 8931:8931 \
  mcr.microsoft.com/playwright/mcp \
  /app/cli.js --headless --browser chromium --no-sandbox --port 8931 --host 0.0.0.0

Expected behavior

http binds to 0.0.0.0 when so configured

Actual behavior

http binds to 127.0.0.1 instead

Additional context

Line 56 of packages/playwright-core/src/tools/utils/mcp/http.ts replaces 0.0.0.0 with localhost when the normalizeloopback option is set (and this is only called in one place and is always set). 0.0.0.0 is not a loopback address, and doing this translation prevents non-localhost use without the explicit specification of an interface IP (and entirely so in a container environment where no such IP is available)

Environment

irrelevant

Activity

  1. dgozman commented on Sep 29, 2026

    @dgozman
    Collaborator

    yeasah Have you tried passing --allowed-hosts=*, explicitly allowing any host to connect to your mcp server?

  2. yeasah commented on Sep 29, 2026

    @yeasah
    Author

    yeasah Have you tried passing --allowed-hosts=*, explicitly allowing any host to connect to your mcp server?

    Well, that may also be required depending on the setup, but without the ability to bind to an externally accessible interface (which the proposed fix addresses) no such connection can be attempted in the first place; the connection attempt will simply not reach the MCP server at all.

  3. dgozman commented on Sep 29, 2026

    @dgozman
    Collaborator

    Well, that may also be required depending on the setup, but without the ability to bind to an externally accessible interface (which the proposed fix addresses) no such connection can be attempted in the first place; the connection attempt will simply not reach the MCP server at all.

    I believe that passing 0.0.0.0 is actually binding on the externally available interface already. It might be printing the wrong address, or not allowing all the hosts to connect, but it listens on the right interface already. Have you tried connecting to it after passing --allowed-hosts=*?

  4. yeasah commented on Sep 29, 2026

    @yeasah
    Author

    Well, that is possible. I ultimately used an MCP proxy in an adjacent container, so it's less relevant to me personally. Looking at my docker config, it does contain PLAYWRIGHT_MCP_ALLOWED_HOSTS=*, but I certainly could have added it after giving up on being able to get a direct connection to happen.

    In any case, whether the actual binding is correct or not, the translation is not, and I don't really understand the controversy here. At a minimum there is a misleading message printed prominently. This is the relevant code, and I think it's a little hard to defend:

      if (options.normalizeLoopback && (host === '0.0.0.0' || host === '[::]' || host === '[::1]' || host === '127.0.0.1'))
        host = 'localhost';
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions