XTLS/Xray-core · error · errors.Error

target not specified.

Error message

target not specified.

What it means

HTTP outbound's Process found the session's last outbound has an invalid Target. Like freedom, the HTTP CONNECT client needs a concrete destination to request from the proxy; without it the request line cannot be built and the handler bails immediately.

Source

Thrown at proxy/http/client.go:73

	server, err := protocol.NewServerSpecFromPB(config.Server)
	if err != nil {
		return nil, errors.New("failed to get server spec").Base(err)
	}

	v := core.MustFromContext(ctx)
	return &Client{
		server:        server,
		policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
		header:        config.Header,
	}, nil
}

// Process implements proxy.Outbound.Process. We first create a socket tunnel via HTTP CONNECT method, then redirect all inbound traffic to that tunnel.
func (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
	outbounds := session.OutboundsFromContext(ctx)
	ob := outbounds[len(outbounds)-1]
	if !ob.Target.IsValid() {
		return errors.New("target not specified.")
	}
	ob.Name = "http"
	ob.CanSpliceCopy = 2
	target := ob.Target
	targetAddr := target.NetAddr()

	if target.Network == net.Network_UDP {
		return errors.New("UDP is not supported by HTTP outbound")
	}

	server := c.server
	dest := server.Destination
	user := server.User
	var conn stat.Connection

	mbuf, _ := link.Reader.ReadMultiBuffer()
	len := mbuf.Len()
	firstPayload := bytespool.Alloc(len)

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Ensure the inbound produces a valid destination before routing to the http outbound
  2. Fix routing so only fully-qualified traffic (with host:port) reaches this outbound
  3. Programmatic users: set outbound.Target before dispatch
Defensive patterns

Strategy: validation

Validate before calling

```go
obs := session.OutboundsFromContext(ctx)
if len(obs) == 0 || !obs[len(obs)-1].Target.IsValid() {
    // refuse before dispatching to the http outbound
}
```

Type guard

```go
func lastTargetValid(ctx context.Context) bool {
    obs := session.OutboundsFromContext(ctx)
    return len(obs) > 0 && obs[len(obs)-1].Target.IsValid()
}
```

Prevention

When it happens

Trigger: Dispatcher routes a session to the HTTP outbound where ob.Target was never populated (inbound failed to parse destination, or a chained handler did not propagate it).

Common situations: Routing rules sending target-less traffic (internal, metadata-less) to the HTTP outbound; transparent inbound without original-dst recovery; custom outbounds not calling SetTarget.

Related errors


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