XTLS/Xray-core · error

interface name must be utunN, where N is a number, e.g…

Error message

interface name must be utunN, where N is a number, e.g. utun9, utun11 and so on

What it means

Darwin tun open(): the requested interface name did not match the "utunN" pattern (or N was negative). macOS utun control sockets are opened by index parsed from the name, so any other name is unusable.

Solutions

  1. Name the interface utun followed by a number, e.g. utun9
  2. Let the system assign a name instead of hardcoding an invalid one
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at proxy/tun/tun_darwin.go:259 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/24e92164a9dfe1ab. Report an issue: GitHub.

Appendix: source

Thrown at proxy/tun/tun_darwin.go:259

		},
	}), nil
}

// Wait some cpu cycles
func (t *DarwinTun) Wait() {
	procyield(1)
}

func (t *DarwinTun) newEndpoint() (stack.LinkEndpoint, error) {
	return &LinkEndpoint{deviceMTU: t.options.MTU, device: t}, nil
}

// open the interface, by creating new utunN if in the system and returning its file descriptor
func open(name string) (*os.File, error) {
	ifIndex := -1
	_, err := fmt.Sscanf(name, "utun%d", &ifIndex)
	if err != nil || ifIndex < 0 {
		return nil, errors.New("interface name must be utunN, where N is a number, e.g. utun9, utun11 and so on")
	}

	fd, err := unix.Socket(unix.AF_SYSTEM, unix.SOCK_DGRAM, sysprotoControl)
	if err != nil {
		return nil, err
	}

	ctlInfo := &unix.CtlInfo{}
	copy(ctlInfo.Name[:], utunControlName)
	if err := unix.IoctlCtlInfo(fd, ctlInfo); err != nil {
		_ = unix.Close(fd)
		return nil, err
	}

	sockaddr := &unix.SockaddrCtl{
		ID:   ctlInfo.Id,
		Unit: uint32(ifIndex) + 1,
	}

View on GitHub (pinned to 7d214f8b09)