Skip to content

127.0.0.1, ::1, localhost #1382

Closed
Closed

Description

@eyes4

macos 14.3,macbook m4环境下,brook客户端版本:Version 20240214 (220240107)
brook服务端采用server模式
当brook开启时,本地调试web服务,侦听0.0.0.0:8000,浏览器上无法通过http://localhost:8000,http://127.0.0.1:8000或http://局域网地址:8000打开网页,brook关闭时就正常。

Activity

  1. txthinking commented on Aug 14, 2025

    @txthinking
    Owner

    本地调试web服务,侦听0.0.0.0:8000

    不同语言对于 0.0.0.0 的实现不同。如果监听了了 0.0.0.0:8080,可以尝试访问 [::1]:8080

    如果 [::1]:8080 也无法访问

    则明确监听 127.0.0.1:8080 或 [::1]:8080

    localhost:8080

    localhost 这个我之前好像测试过,不同系统和请求端对于指向 127.0.0.1 还是 ::1 以及预加载hosts实现有差异

    我一般(在 mac 上,双栈)

    1. 明确监听 ::1
    2. 基本不使用 localhost
    3. 如果一定要使用域名,可以用 module,明确配置一个额外的域名指向 ::1
      // hosts
      modules = append(modules, {
          dnsquery: func(m) {
              if m.domain == "localhost.com" {
                  if m.type == "A" {
                      return {block: true}
                  }
                  if m.type == "AAAA" {
                      return {ip: "::1"}
                  }
              }
          }
      })
      
  2. changed the title [-]macos 14.3[/-] [+]127.0.0.1, ::1, localhost[/+] on Aug 14, 2025
  3. pinned this issue on Aug 14, 2025
  4. eyes4 commented on Aug 14, 2025

    @eyes4
    Author

    用IPv6侦听::1,问题解决👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions