sveltejs/kit · error · Error

${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddr

Error message

${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddress. Please raise an issue

What it means

The `getClientAddress` event method is supplied by the server adapter via `state.getClientAddress`. When no adapter (or emulator) provides it, SvelteKit installs a fallback that throws, since the framework cannot know the platform-specific way to read the client IP.

Source

Thrown at packages/kit/src/runtime/server/respond.js:193

	}

	/** @type {Record<string, string>} */
	const headers = {};

	const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(
		request,
		url
	);

	/** @type {import('@sveltejs/kit').RequestEvent} */
	const event = {
		cookies,
		// @ts-expect-error `fetch` needs to be created after the `event` itself
		fetch: null,
		getClientAddress:
			state.getClientAddress ||
			(() => {
				throw new Error(
					`${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddress. Please raise an issue`
				);
			}),
		locals: {},
		params: {},
		platform: state.emulator?.platform
			? await state.emulator.platform({
					config: {},
					prerender: !!state.prerendering?.fallback
				})
			: state.platform,
		request,
		route: { id: null },
		setHeaders: (new_headers) => {
			if (DEV) {
				validateHeaders(new_headers);
			}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Use an adapter that implements getClientAddress (e.g. adapter-node) or the adapter's platform object for IP
  2. Read the IP from headers (e.g. `x-forwarded-for`) via `event.request.headers.get` instead
  3. Guard the call and fall back to a placeholder when running outside a real server

Example fix

// before
const ip = event.getClientAddress();
// after
const ip = event.request.headers.get('x-forwarded-for')?.split(',')[0] ?? 'unknown';
Defensive patterns

Strategy: fallback

Validate before calling

// prefer forwarded headers when socket info is unavailable
const ip = request.headers.get('x-forwarded-for')?.split(',')[0]?.trim();

Try / catch

let ip;
try {
  ip = event.getClientAddress();
} catch {
  ip = event.request.headers.get('x-forwarded-for')?.split(',')[0] ?? 'unknown';
}

Prevention

When it happens

Trigger: Code calls `event.getClientAddress()` in dev/prod where `state.getClientAddress` is undefined — typically running the built server output directly without its adapter runtime, or an adapter that does not implement getClientAddress.

Common situations: Accessing client IP in an environment without socket info (Cloudflare Workers-style runtimes, some emulators); executing server output with a plain Node harness instead of the adapter entry; relying on client IP behind proxies that don't forward it.

Related errors


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