sveltejs/kit · error · Error

Address header was specified with ${env_prefix + 'ADDRESS_HE

Error message

Address header was specified with ${env_prefix + 'ADDRESS_HEADER'}=${address_header} but is absent from request

What it means

When ADDRESS_HEADER is configured, adapter-node derives the client address from that request header inside getClientAddress instead of the socket. If the header is missing from the incoming request, this error is thrown because the server cannot determine the client address.

Source

Thrown at packages/adapter-node/src/handler.js:151

	try {
		request = getRequest({
			base: request_origin,
			request: req,
			response: res,
			bodySizeLimit: body_size_limit
		});
	} catch {
		res.statusCode = 400;
		res.end('Bad Request');
		return;
	}

	const response = await server.respond(request, {
		platform: { req },
		getClientAddress: () => {
			if (address_header) {
				if (!(address_header in req.headers)) {
					throw new Error(
						`Address header was specified with ${
							env_prefix + 'ADDRESS_HEADER'
						}=${address_header} but is absent from request`
					);
				}

				const value = /** @type {string} */ (req.headers[address_header]) || '';

				if (address_header === 'x-forwarded-for') {
					const addresses = value.split(',');

					if (xff_depth < 1) {
						throw new Error(`${env_prefix + 'XFF_DEPTH'} must be a positive integer`);
					}

					if (xff_depth > addresses.length) {
						throw new Error(
							`${env_prefix + 'XFF_DEPTH'} is ${xff_depth}, but only found ${

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Ensure the reverse proxy always sets the configured ADDRESS_HEADER on every request
  2. Change ADDRESS_HEADER to a header your proxy actually provides (e.g. x-forwarded-for)
  3. Unset ADDRESS_HEADER to fall back to the socket address

Example fix

// before
ADDRESS_HEADER=x-real-ip  # proxy never sets it
// after
ADDRESS_HEADER=x-forwarded-for
Defensive patterns

Strategy: fallback

Try / catch

try {
  await fetch(url);
} catch (err) {
  if (String(err.message).includes('but is absent from request')) {
    console.error(`Proxy is not setting ${process.env.ADDRESS_HEADER}; fix proxy config or unset ADDRESS_HEADER`);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: A request reaches the SSR handler while env var ADDRESS_HEADER is set (e.g. 'x-client-ip') but the request lacks that header.

Common situations: Deploying behind a proxy that does not actually inject the configured header, or testing locally with curl where the header was never set.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/4fc6ea209b435c1a. Report an issue: GitHub.