# 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.

Source: https://livops.dev/en/guides/error-next-image-hostname-not-configured

By Livops team, the people who build and run Livops. Updated 1 December 2026.

What Next.js prints while you run `next dev`[5]:

```text
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]:

```js
// 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]:

```ts
// 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.

```js
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:

```js
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:

```js
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:

```jsx
<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]:

```js
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]:

```js
// next.config.js
module.exports = {
  images: {
    loader: "custom",
    loaderFile: "./image-loader.js",
  },
};
```

```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

1. Restart `next dev` and open the page. The error is gone and the image shows.
2. Build and run production locally: `next build && next start`.
3. In the browser's developer tools, on the **Network** tab, find the image's request to `/_next/image?url=...`. It should answer `200`. A `400` whose body says `"url" parameter is not allowed` means the pattern still does not match[6]; copy the `url` value 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 push` to the connected branch starts a new deploy, which builds the app again, so a fixed `next.config.js` takes 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/image` runs with it. A static export is a static site, which is free on Livops; there, as above, use `unoptimized` or a custom loader. If the build output folder is not found, set it in **Settings → Output**. See [No site found](https://livops.dev/en/docs/error-output).
- **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=640` is not available yet, so a custom loader cannot ask Livops for a smaller size; prepare the sizes yourself and use `srcset`. See [Image optimization](https://livops.dev/en/docs/images).

If the build itself fails, see [Module not found: Can't resolve](https://livops.dev/en/guides/error-module-not-found-cant-resolve) or [JavaScript heap out of memory in next build](https://livops.dev/en/guides/error-next-build-heap-out-of-memory). If images load over `http://` on an HTTPS page, see [Mixed Content](https://livops.dev/en/guides/error-mixed-content-blocked).

## 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

1. [Next.js Docs — next/image Un-configured Host](https://nextjs.org/docs/messages/next-image-unconfigured-host). Checked 1 December 2026.
2. [Next.js Docs — Image Component](https://nextjs.org/docs/app/api-reference/components/image). Checked 1 December 2026.
3. [Next.js Docs — next.config.js](https://nextjs.org/docs/app/api-reference/config/next-config-js). Checked 1 December 2026.
4. [Next.js Docs — Static Exports](https://nextjs.org/docs/app/guides/static-exports). Checked 1 December 2026.
5. [Next.js source — packages/next/src/shared/lib/image-loader.ts](https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/src/shared/lib/image-loader.ts). Checked 1 December 2026.
6. [Next.js source — packages/next/src/server/image-optimizer.ts](https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/src/server/image-optimizer.ts). Checked 1 December 2026.
7. [Next.js source — packages/next/src/server/next-server.ts](https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/src/server/next-server.ts). Checked 1 December 2026.
