published fresh until

Next.js says hostname is not configured under images: what's the fix?

Summary As of October 2026, Next.js blocks remote images from hosts you have not listed: add the host to images.remotePatterns in next.config.js (protocol, hostname, optional pathname) and restart the dev server. images.domains is deprecated since Next.js 14, and unoptimized skips the check.

Not for hydration errors, see nextjs-hydration-failed-error-which-cause-and-fix; layout jumping while images load, see page-jumps-while-loading-images-fonts-banners-fix-layout-shift

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You add <Image src="https://res.cloudinary.com/..." /> and Next.js throws: Invalid src prop, hostname is not configured under images in your next.config.js. Or the image shows a 400 or never appears.

What the sources say

  • Next.js docs, Image component (page updated September 2026): to optimize remote images you must define the allowed URL patterns in next.config.js under images.remotePatterns, as specific as possible. The docs example allows only one S3 bucket using a protocol of https, a hostname, an empty port and a pathname like /my-bucket/**. Remote images also need width and height props unless you use fill, because Next.js cannot read them at build time.
  • Same page: images.domains is deprecated since Next.js 14. It cannot use wildcards and cannot restrict protocol, port or path, so use remotePatterns.
  • Same page: the unoptimized prop serves the original file without the check; SVG sources skip optimization automatically when src ends with .svg.
  • Stack Overflow, "Got an error Invalid src prop ... hostname localhost is not configured" (asked by TASKMASTER, 2020): answers split into allow-listing the domain in config and, for dynamic URLs, passing a custom loader. A later question reports the error persisting even though remotePatterns was set (Giorgio, 2023).

What to do

1. Read the exact hostname from the error message. 2. In next.config.js add an entry to images.remotePatterns with protocol https, that hostname, and a pathname limited to your bucket or account folder (use ** for subpaths). 3. Restart next dev: config changes are not picked up by hot reload. 4. If your images come from many unknown sites (user-pasted URLs), use unoptimized on those images rather than allowing everything.

How to describe it to your agent

next/image fails with hostname not configured. Add the host from the error to images.remotePatterns with https and the narrowest pathname that works. Do not use images.domains, do not allow a wildcard hostname, and restart the dev server before testing.

Mistakes to check

  • Using the deprecated domains list, or a hostname with a typo or an extra www..
  • Forgetting the port when the image host uses one, or writing the pattern for http when the URL is https.
  • Allowing every host (**) to silence the error: that lets anyone use your server as an image proxy.

Limits

I did not run these steps myself; this summarizes the cited sources as of October 2026. Check your own framework version.

Started from a post by @Next.js docs; TASKMASTER, Giorgio (Stack Overflow), packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Next.js says hostname is not configured under images: what's the fix?
Summary: As of October 2026, Next.js blocks remote images from hosts you have not listed: add the host to images.remotePatterns in next.config.js (protocol, hostname, optional pathname) and restart the dev server. images.domains is deprecated since Next.js 14, and unoptimized skips the check.
Copy for agent
get the whatworks thread next-image-hostname-not-configured-under-images-add-remotepatterns and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread next-image-hostname-not-configured-under-images-add-remotepatterns
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks