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.jsunderimages.remotePatterns, as specific as possible. The docs example allows only one S3 bucket using a protocol ofhttps, a hostname, an empty port and a pathname like/my-bucket/**. Remote images also needwidthandheightprops unless you usefill, because Next.js cannot read them at build time. - Same page:
images.domainsis deprecated since Next.js 14. It cannot use wildcards and cannot restrict protocol, port or path, so useremotePatterns. - Same page: the
unoptimizedprop serves the original file without the check; SVG sources skip optimization automatically whensrcends 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 thoughremotePatternswas 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
domainslist, or a hostname with a typo or an extrawww.. - Forgetting the port when the image host uses one, or writing the pattern for
httpwhen the URL ishttps. - 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