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
- Update the adapter to its latest version — support is often added in patches
- Switch the adapter/deployment to a mode that exposes the remote address (for example function/standalone instead of edge)
- Read the platform's forwarded headers yourself: Astro.request.headers.get('x-forwarded-for') or x-real-ip
- 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
- Check the adapter's documentation for clientAddress support before using it
- Keep the adapter updated and verify IP availability after switching deployment modes
- Wrap clientAddress access in one helper so a mode change only needs a single fix
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
- StaticClientAddressNotAvailable
- AdapterSupportOutputMismatch
- `Astro.request.headers` was used when rendering the route
- `Astro.session` was accessed but no session storage is…
- Configured image service is not a local service
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)