Invalid src prop on next/image, hostname is not configured under images in your next.config.js: how to fix it
Invalid src prop (https://…) on next/image, hostname "…" is not configured under images in your next.config.js means the image's address does not match any entry in images.remotePatterns. Add the host to remotePatterns with the right protocol, port and path, restart next dev and build again. images.domains is deprecated since Next.js 14. In production the same mismatch shows as a broken image and a 400 from /_next/image.
By Livops team, the people who build and run LivopsUpdated
What Next.js prints while you run next dev[5]:
Invalid src prop (https://cdn.example.com/photos/team.jpg) on `next/image`, hostname "cdn.example.com" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
The message names next.config.js whatever your file is called, so it applies to next.config.mjs and next.config.ts too.
This page explains what Next.js checks, gives the remotePatterns entry that fixes it, lists the reasons a pattern still does not match, and covers the two ways around it, unoptimized and a custom loader.
What does the error mean?
next/image accepts an internal path, a static import, or an absolute external URL, and an external URL must be configured with remotePatterns[2]. The error means one of your pages passed a src whose hostname is not covered by images.remotePatterns in next.config.js[1].
Next.js checks this so that its image optimizer is not an open proxy: remotePatterns allows images from specific external paths and blocks all others[2].
In development you get the error above: the check runs only when NODE_ENV is not production[5]. In production there is no message on the page. The image optimizer at /_next/image refuses the address, and the image is simply broken. Any other protocol, hostname, port or unmatched path is answered with 400 Bad Request[2], and the body is the text "url" parameter is not allowed[6][7].
The fix: add the host to images.remotePatterns
The shortest form, from Next.js 15.3.0, is a URL object[1]:
// next.config.js
module.exports = {
images: {
remotePatterns: [new URL("https://cdn.example.com/photos/**")],
},
};
The object form works in older versions too, and lets you leave out the query string rule[1]:
// next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "cdn.example.com",
port: "",
pathname: "/photos/**",
},
],
},
};
export default nextConfig;
next.config.ts is supported for TypeScript projects[3]. Be as specific as you can; the docs’ own example allows one S3 bucket, not all of S3[2].
Then restart and rebuild. next.config.js is used by the Next.js server and build phases[3], so a change reaches production only through a new build. Locally, restart next dev if the error does not go away; for production, run next build again and deploy the result.
Why the pattern still does not match
Each part of the src is matched strictly against your patterns, and matching is exact and case-sensitive: a mismatch in any single part fails the check[1]. Compare the address in the error with your pattern, part by part[1]:
| Part | What must match | Common mistake |
|---|---|---|
| Protocol | http or https, exactly |
https in src, only http allowed, or the other way round |
| Hostname | the full host | example.com allowed, image on www.example.com or assets.example.com |
| Port | the port, if the URL has one | http://localhost:3000 without port: "3000" |
| Pathname | covered by the glob | /images/ instead of /images/** |
| Search | the full query string, including ?, if the pattern sets one |
a URL object without a query string allows no query string |
The last row catches people who switch to the URL form: when you create a URL with no search, its search is an empty string, which means search params are not allowed[1]. An image address like https://cdn.example.com/photos/team.jpg?v=3 is then rejected. To allow any query string, use the object form and leave out search[1]. To allow one exact query, put it in the URL: new URL("https://cdn.example.com/photos/**?v=1234")[1].
Wildcards
pathname and hostname take wildcards[2]:
*matches a single path segment or subdomain.**matches any number of path segments at the end, or subdomains at the beginning. It does not work in the middle of a pattern.
remotePatterns: [
{
protocol: "https",
hostname: "**.example.com",
port: "",
search: "",
},
],
That allows subdomains such as image.example.com; query strings and custom ports are still blocked[2].
Leaving out protocol, port, pathname or search implies ** for that field[2]. It makes the error go away, and Next.js does not recommend it, because it may let others optimize URLs you did not intend[2].
images.domains is deprecated
Old tutorials show this:
images: {
domains: ["cdn.example.com"],
},
domains is deprecated since Next.js 14 in favor of the stricter remotePatterns; it does not support wildcards and cannot restrict the protocol, port or pathname[2]. Replace it:
images: {
remotePatterns: [
{ protocol: "https", hostname: "cdn.example.com", pathname: "/**" },
],
},
The host is allowed and you still get 400
One case looks like this error in production but is not about the pattern: the image host resolves to a private IP address. images.dangerouslyAllowLocalIP is false by default[2], and the optimizer then answers 400 with the same "url" parameter is not allowed[6]. Setting it to true allows optimizing images from local IP addresses; the docs say it might be needed when self-hosting in a private network with split-horizon DNS and you receive 400 Bad Request, and to enable it only once you understand the SSRF risk[2]. Most apps should not need it.
Without remotePatterns: unoptimized or a loader
unoptimized. The image is served as-is from its src, without changing its quality, size or format[2]. Next.js names small images, SVG and animated GIF as the cases that do not benefit from optimization[2], and suggests it for images that need authentication, because the default loader does not forward headers[2]. For one image:
<Image src="https://cdn.example.com/photos/team.jpg" alt="Our team" width={800} height={600} unoptimized />
For every image, since Next.js 12.3.0[2]:
module.exports = {
images: {
unoptimized: true,
},
};
A custom loader. If another service resizes your images, give next/image a function that receives src, width and quality and returns the image’s URL[2], either as the loader prop on one image or for every image with loaderFile[2]:
// next.config.js
module.exports = {
images: {
loader: "custom",
loaderFile: "./image-loader.js",
},
};
// image-loader.js
export default function imageLoader({ src, width, quality }) {
return `https://images.example.com/${src}?w=${width}&q=${quality || 75}`;
}
With output: 'export' there is no server, and Image Optimization with the default loader is not supported[4]. Use unoptimized, or a custom loader for an image service[4].
How to confirm the fix
- Restart
next devand open the page. The error is gone and the image shows. - Build and run production locally:
next build && next start. - In the browser’s developer tools, on the Network tab, find the image’s request to
/_next/image?url=.... It should answer200. A400whose body says"url" parameter is not allowedmeans the pattern still does not match[6]; copy theurlvalue and compare it with the table above.
On Livops
- Next.js is detected. Livops detects Next.js and fills in the install and build commands. Every
git pushto the connected branch starts a new deploy, which builds the app again, so a fixednext.config.jstakes effect with that push. - Server or static. A Next.js app that renders pages on the server is deployed as an Application, not a static site, and the built-in optimizer at
/_next/imageruns with it. A static export is a static site, which is free on Livops; there, as above, useunoptimizedor a custom loader. If the build output folder is not found, set it in Settings → Output. See No site found. - Images on a static site. When you deploy a static site, Livops makes a WebP copy of every JPEG and PNG over 100 KB in it and serves the WebP at the same address to browsers that support it. That covers the files in your build, not images on other hosts. On-demand resizing such as
?w=640is not available yet, so a custom loader cannot ask Livops for a smaller size; prepare the sizes yourself and usesrcset. See Image optimization.
If the build itself fails, see Module not found: Can’t resolve or JavaScript heap out of memory in next build. If images load over http:// on an HTTPS page, see Mixed Content.
Questions
I added the domain to next.config.js. Why do I still get the error?
Either the server is still running with the old config, or the pattern does not match the address exactly. Restart next dev and build again for production. Then compare every part: https versus http, www versus no www, a subdomain, a port, a path pattern that must end in two asterisks to cover the folder, and a query string that your pattern does not allow.
Is images.domains still supported?
It is deprecated since Next.js 14 in favor of remotePatterns. It cannot use wildcards or restrict the protocol, port or path. Use remotePatterns with a protocol and hostname instead.
How do I allow every subdomain of a domain?
Put a wildcard at the start of hostname, followed by .example.com: two asterisks match any number of subdomains at the beginning, one asterisk matches a single subdomain. Keep the protocol set, so plain http is not allowed by accident.
Can I allow any image host at all?
You can leave fields out of a pattern, and a missing field counts as a wildcard, but Next.js advises against it: anyone could then use your server to optimize images from anywhere. List the hosts you actually use.
Why does the error appear in development but not in production?
Next.js checks the hostname and throws this error only in development. In production the image optimizer at /_next/image answers 400 Bad Request for an address that is not allowed, so you see a broken image instead of a message.
What if I do not want Next.js to optimize remote images at all?
Add the unoptimized prop to the image, or set images.unoptimized to true in next.config.js for every image. The image is then served as-is from its own address. A custom loader is the other way out, when another service resizes your images.
Do I need remotePatterns with output export?
A static export cannot use the default image loader, which needs a server. Use unoptimized images or a custom loader that points at an image service.
Sources
- Next.js Docs — next/image Un-configured Host (nextjs.org). Checked .
- Next.js Docs — Image Component (nextjs.org). Checked .
- Next.js Docs — next.config.js (nextjs.org). Checked .
- Next.js Docs — Static Exports (nextjs.org). Checked .
- Next.js source — packages/next/src/shared/lib/image-loader.ts (raw.githubusercontent.com). Checked .
- Next.js source — packages/next/src/server/image-optimizer.ts (raw.githubusercontent.com). Checked .
- Next.js source — packages/next/src/server/next-server.ts (raw.githubusercontent.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Next.js appRelated
- Next.js hosting without Vercel: the options comparedNext.js runs on any host that runs Node: next build, then next start, and every feature works, Server Actions and image optimization included. On Livops a repository with next in package.json runs as a server from a push for 39 credits a month (39,000 so'm), and a static export is free. Here is how Vercel, Render, Railway, Fly.io and a VPS compare.
- Module not found: Can't resolve './components/Header' in webpack and Next.js: how to fix itModule not found: Can't resolve './components/Header' means the bundler followed an import and found no file or package there. The usual causes: the file name's case differs from the import (fine on macOS and Windows, fatal on a Linux build server), a wrong relative path or a missing extension, a package that is not in package.json, an @/ alias the bundler does not know, and, for Can't resolve 'fs', Node-only code pulled into the browser bundle.
- JavaScript heap out of memory during next build: how to fix itNode's JavaScript heap reached its limit while Next.js was building, and V8 stopped the process. Raise the heap limit with NODE_OPTIONS=--max-old-space-size, staying below the memory the build really has, and cut what the build holds in memory: source maps, type checking during the build, and heavy dependencies.
- Mixed Content: the page was loaded over HTTPS, but requested an insecure resource — fix after deployMixed Content: The page at 'https://…' was loaded over HTTPS, but requested an insecure resource 'http://…'. This request has been blocked means your HTTPS page asked for a script, stylesheet or API call over plain http://, and the browser refused. After a deploy the usual reasons are an API address with http:// baked into the frontend build, or a backend behind an HTTPS proxy that builds its URLs with http://. Use https:// or relative URLs, rebuild, and make the backend trust its proxy.
- Free static site hosting in 2026: the free tiers comparedA static site — plain HTML, or a Vite, React or Astro build, or a Lovable export — is free on all five. The differences are the limits: Netlify pauses every site when 300 monthly credits run out, Vercel Hobby is for non-commercial use only, GitHub Pages is not for running a business, and Cloudflare Pages does not count static traffic. On Livops up to 30 sites are free, on your own domain, with no card asked for.
- Vercel alternatives in 2026: for Next.js and for backendsNetlify is the closest swap for a Next.js frontend on a global network; Cloudflare has the cheapest one, with free static requests; Render, Railway and Fly.io run Next.js as an ordinary server, with long-running services beside it; Coolify runs it on a server you rent. Livops fits users in Uzbekistan: static sites free, a server-rendered Next.js app 39 credits a month and a bot or worker 19, paid through Payme or Click, with no card.