withastro/astro · error · AstroError

ClientAddressNotAvailable

ClientAddressNotAvailable

Error message

`Astro.clientAddress` is not available in the `${adapterName}` adapter. File an issue with the adapter to add support.

What it means

When no clientAddress was attached to the request state and the manifest names an adapter, getClientAddress() throws AstroErrorData.ClientAddressNotAvailable. The configured adapter did not hand Astro a trusted client IP for this request — either the adapter never implements it, or it is running in a mode (often edge/split modes) where the socket address is not visible to the app.

Solutions

  1. Update the adapter to its latest version — support is often added in patches
  2. Switch the adapter/deployment to a mode that exposes the remote address (for example function/standalone instead of edge)
  3. Read the platform's forwarded headers yourself: Astro.request.headers.get('x-forwarded-for') or x-real-ip
  4. If nothing works, file an issue with the adapter as the error message suggests

Example fix

// before
const ip = Astro.clientAddress;

// after
const ip =
  Astro.request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ??
  Astro.request.headers.get('x-real-ip');
Defensive patterns

Strategy: fallback

Validate before calling

function getClientIp(request: Request): string | null {
  return (
    request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ??
    request.headers.get('x-real-ip')
  );
}
// use getClientIp(Astro.request) when the adapter does not provide Astro.clientAddress

Try / catch

let ip: string;
try {
  ip = Astro.clientAddress;
} catch {
  ip = getClientIp(Astro.request) ?? 'unknown';
}

Prevention

When it happens

Trigger: Astro.clientAddress on a server-rendered route while using an adapter that does not provide the address in the current deployment mode; upgrading an adapter to a version that changed which modes expose the IP; running the adapter's edge variant.

Common situations: Switching @astrojs/vercel or @astrojs/netlify to edge/split mode where no reverse-proxy IP is forwarded; using an older or minimal adapter; deploying behind a platform whose adapter build has no clientAddress support yet.

Related errors


AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18). Data as JSON: /api/errors/a33e8d7dee9c1454. Report an issue: GitHub.

Appendix: source

Thrown at packages/astro/src/core/fetch/fetch-state.ts:647

	}

	getClientAddress(): string {
		const { clientAddress } = this;
		const routeData = this.routeData!;

		if (routeData.prerender) {
			throw new AstroError({
				...AstroErrorData.PrerenderClientAddressNotAvailable,
				message: AstroErrorData.PrerenderClientAddressNotAvailable.message(routeData.component),
			});
		}

		if (clientAddress) {
			return clientAddress;
		}

		if (this.manifest.adapterName) {
			throw new AstroError({
				...AstroErrorData.ClientAddressNotAvailable,
				message: AstroErrorData.ClientAddressNotAvailable.message(this.manifest.adapterName),
			});
		}

		throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
	}

	getCookies(): AstroCookies {
		return this.cookies;
	}

	getCsp(): APIContext['csp'] {
		const state = this;
		if (!this.manifest.csp) {
			if (getEnvironment(this.manifest).runtimeMode === 'production') {
				this.logger.warn(
					'csp',

View on GitHub (pinned to e294953aa8)