next/image hostname ⚛️ React

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

  1. Add the host to images.remotePatterns
  2. Restart the dev server after changing next.config.js

Detailed fix by platform

React

  1. images: { remotePatterns: [{ protocol: 'https', hostname: 'cdn.example.com' }] }

How to diagnose

  1. Host — Which hostname?
  2. 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.