XTLS/Xray-core · error
Tun is not supported on your platform
Error message
Tun is not supported on your platform
What it means
Guard error from the stub TUN implementation compiled when none of the supported build tags (linux, windows, android, darwin, freebsd) match the build target. NewTun (and every DefaultTun method) is an unconditional sentinel that always fails, meaning the platform simply has no TUN device support compiled in.
Solutions
- Build or run xray on a supported platform: linux, windows, android, darwin, or freebsd
- Remove or disable the TUN inbound/outbound from the configuration on unsupported platforms
- Add a platform-specific implementation of the Tun interface for the target OS and add its build tag to the build constraint
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at proxy/tun/tun_default.go:19 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/bdace7d13e71ea4c.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/tun/tun_default.go:19
//go:build !linux && !windows && !android && !darwin && !freebsd
package tun
import (
"net"
"github.com/xtls/xray-core/common/errors"
"gvisor.dev/gvisor/pkg/tcpip/stack"
)
type DefaultTun struct{}
// DefaultTun implements Tun
var _ Tun = (*DefaultTun)(nil)
// NewTun builds new tun interface handler
func NewTun(options *Config) (Tun, error) {
return nil, errors.New("Tun is not supported on your platform")
}
func (t *DefaultTun) Start() error {
return errors.New("Tun is not supported on your platform")
}
func (t *DefaultTun) Close() error {
return errors.New("Tun is not supported on your platform")
}
func (t *DefaultTun) Name() (string, error) {
return "", errors.New("Tun is not supported on your platform")
}
func (t *DefaultTun) Index() (int, error) {
return 0, errors.New("Tun is not supported on your platform")
}
View on GitHub (pinned to 7d214f8b09)