XTLS/Xray-core · error

invalid protocol or invalid user

Error message

invalid protocol or invalid user

What it means

Trojan server Process rejects the connection outright when the first bytes were not trojan protocol or the user hash was unknown AND no fallback destination is configured for the inbound; there is nowhere to divert the connection, so the raw validation error is returned.

Solutions

  1. Configure fallbacks on the inbound to serve non-Trojan traffic
  2. Fix the client's credentials/protocol if Trojan was expected
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at proxy/trojan/server.go:206 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/3d85cadfc637a2e2. Report an issue: GitHub.

Appendix: source

Thrown at proxy/trojan/server.go:206

		user = s.validator.Get(hexString(first.BytesTo(56)))
		if user == nil {
			// invalid user, let's fallback
			err = errors.New("not a valid user")
			log.Record(&log.AccessMessage{
				From:   conn.RemoteAddr(),
				To:     "",
				Status: log.AccessRejected,
				Reason: err,
			})

			shouldFallback = true
		}
	}

	if isfb && shouldFallback {
		return s.fallback(ctx, err, sessionPolicy, conn, iConn, napfb, first, firstLen, bufferedReader)
	} else if shouldFallback {
		return errors.New("invalid protocol or invalid user")
	}

	clientReader := &ConnReader{Reader: bufferedReader}
	if err := clientReader.ParseHeader(); err != nil {
		log.Record(&log.AccessMessage{
			From:   conn.RemoteAddr(),
			To:     "",
			Status: log.AccessRejected,
			Reason: err,
		})
		return errors.New("failed to create request from: ", conn.RemoteAddr()).Base(err)
	}

	destination := clientReader.Target
	if err := conn.SetReadDeadline(time.Time{}); err != nil {
		return errors.New("unable to set read deadline").Base(err).AtWarning()
	}

View on GitHub (pinned to 7d214f8b09)