projectdiscovery/nuclei · error

no host header found

Error message

no host header found

What it means

The companion error to 'no new line found at the end of host header': during raw-request header rewriting, nuclei first searches for a Host header; if none exists anywhere in the raw request, there is nothing to rewrite/inject against and this error is returned. HTTP/1.1 requests require a Host header, so the raw request is considered malformed.

Source

Thrown at pkg/protocols/http/raw/raw.go:342

			newLineIndex += hostHeaderIndex + 2
			// insert custom headers
			buf := bufferPool.Get().(*bytes.Buffer)
			buf.Reset()
			buf.Write(r.UnsafeRawBytes[:newLineIndex])
			for _, header := range headers {
				buf.WriteString(header)
				buf.WriteString("\r\n")
			}
			buf.Write(r.UnsafeRawBytes[newLineIndex:])
			r.UnsafeRawBytes = append([]byte(nil), buf.Bytes()...)
			buf.Reset()
			bufferPool.Put(buf)
			return nil
		}
		return errors.New("no new line found at the end of host header")
	}

	return errors.New("no host header found")
}

// ApplyAuthStrategy applies the auth strategy to the request
func (r *Request) ApplyAuthStrategy(strategy authx.AuthStrategy) {
	if strategy == nil {
		return
	}
	switch s := strategy.(type) {
	case *authx.QueryAuthStrategy:
		parsed, err := urlutil.Parse(r.FullURL)
		if err != nil {
			gologger.Error().Msgf("auth strategy failed to parse url: %s got %v", r.FullURL, err)
			return
		}
		for _, p := range s.Data.Params {
			parsed.Params.Add(p.Key, p.Value)
		}
		r.FullURL = parsed.String()

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Add a Host header line, typically `Host: {{Hostname}}`, as the first header of the raw request
  2. Include the mandatory blank line after all headers
  3. Validate the template with nuclei -validate before scanning

Example fix

# before
- raw:
    - |
      GET / HTTP/1.1
      Accept: */*

# after
- raw:
    - |
      GET / HTTP/1.1
      Host: {{Hostname}}
      Accept: */*
Defensive patterns

Strategy: validation

Validate before calling

func hasHostHeader(raw string) bool {
    for _, line := range strings.Split(raw, "\n") {
        if strings.HasPrefix(strings.ToLower(strings.TrimSpace(line)), "host:") {
            return true
        }
    }
    return false
}

Prevention

When it happens

Trigger: A raw request template whose header block has no `Host:` line at all, e.g. only 'GET / HTTP/1.1' followed by other headers, while the code path requires locating and rewriting Host.

Common situations: Hand-crafting minimal raw requests and forgetting Host; deleting the Host line assuming {{BaseURL}} substitution makes it unnecessary.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/b4c5bcec861b16c7. Report an issue: GitHub.