Skip to content

Next.js image errorNext.js image error: the hostname isn’t configured

A page using next/image fails with an “Un-configured Host” error, or the remote image never loads. Next.js only optimizes remote images whose address matches a pattern in next.config.js, and the match is exact. Here are the usual mismatches in Next.js’s words, or hand it over at a fixed price.

Short answer

Add the image’s address to images.remotePatterns in next.config.js, with the same protocol, hostname, port and path the src uses. In our experience you then need to restart the dev server or redeploy before the change shows. Most cases we see are a missing subdomain, such as storage or cdn in front of the domain.

Why next/image rejects the image, and the fix

  1. 01

    The image host isn’t in remotePatterns

    “Each part of the src value is strictly matched against your images.remotePatterns definitions.” Next.js, next/image Un-configured Host

    Pictures from a storage bucket, a CMS or another site need their own entry. Add the address with a path pattern that covers the images, and keep it as narrow as the real paths.

    module.exports = {
      images: {
        remotePatterns: [new URL('https://assets.example.com/account123/**')],
      },
    }
  2. 02

    The pattern is close, but not exact

    “Hostname: example.org is different from www.example.org and from subdomains like assets.example.org” Next.js, next/image Un-configured Host

    A pattern for the bare domain doesn’t cover www or a subdomain, and https doesn’t cover http. A port, such as a local server on 3000, has to be listed too, and a path like /images/ needs /** to match the files under it.

  3. 03

    The project still uses images.domains

    “Deprecated since Next.js 14 in favor of strict remotePatterns in order to protect your application from malicious users.” Next.js, Image component

    Older projects and some AI-generated code list hosts under images.domains. Move them to remotePatterns, which can also limit the protocol, port and path.

  4. 04

    The image doesn’t need optimizing

    “This is useful for images that do not benefit from optimization such as small images (less than 1KB), vector images (SVG), or animated images (GIF).” Next.js, Image component

    For an SVG logo, a GIF or a tiny icon, you can set unoptimized on that one image so Next.js serves it as it is. We also prefer this to opening remotePatterns to every host.

Checked against the vendor’s docs on : Next.js docs: next/image Un-configured Host; Next.js docs: Image component.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Next.js hydration error · Vercel 404 on a Ready deployment · Next.js DynamicServerError · Next.js Server Action body limit

Questions

More on this error

Can we allow every hostname with a wildcard?

Next.js advises against it, because leaving out parts of a pattern may let anyone use your app to optimize images you didn’t intend. List the hosts you really load images from.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.