Error: Invalid src prop on `next/image`, hostname "x" is not configured under images in your `next.config.js`
next/image refuses to optimize images from domains not allowed in next.config.js.
Seen on:
React
Meaning
Remote images need images.remotePatterns (or the older images.domains) so the optimizer can’t be abused as an open proxy.
Common causes
- New image CDN/host not added
- Using domains in Next 14+ where remotePatterns is preferred
- Protocol/port mismatch in the pattern
⚡ Quick fix
- Add the host to images.remotePatterns
- Restart the dev server after changing next.config.js
Detailed fix by platform
React
images: { remotePatterns: [{ protocol: 'https', hostname: 'cdn.example.com' }] }
How to diagnose
- Host — Which hostname?
- Config — remotePatterns entry matches?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026