← All errors · Next.jsNext.js App Router & config errors

Invalid src prop on next/image, hostname is not configured

Exact error

Error: Invalid src prop (https://example.com/a.png) on `next/image`, hostname "example.com" is not configured under images in your `next.config.js`

What it means

next/image only optimizes remote images whose URL matches an entry in images.remotePatterns. Every part (protocol, hostname, port, pathname, search) is matched exactly and case-sensitively.

Likely causes

How to fix it

  1. Add the host to remotePatterns in next.config. Use the object form; leaving out search allows any query string:

    // next.config.js
    module.exports = {
      images: {
        remotePatterns: [
          { protocol: 'https', hostname: 'example.com', pathname: '/**' },
          { protocol: 'https', hostname: '*.supabase.co', pathname: '/storage/v1/object/public/**' },
        ],
      },
    };
  2. On Next.js 15.3 or newer you can also pass a URL object, e.g. new URL('https://assets.example.com/account123/**'). On versions before 12.3, use images.domains instead.

  3. Restart the dev server. next.config changes are not hot-reloaded.

Still stuck after trying this? Get it fixed for $49, or you don't pay.

Prevent this next time

FAQ

What does "Invalid src prop on next/image, hostname is not configured" mean?

next/image only optimizes remote images whose URL matches an entry in images.remotePatterns. Every part (protocol, hostname, port, pathname, search) is matched exactly and case-sensitively.

What usually causes it?

Loading an image from a new domain (e.g. Supabase Storage, a CDN) without allow-listing it. The pattern is close but not exact: https vs http, www.example.com vs example.com, a subdomain like assets.example.com, or a missing port such as :3000. The pathname pattern is too narrow, e.g. /images/ instead of /images/**. The URL has query params (?v=123) but the pattern was built with new URL() and no search, which allows no query string.

How do I fix it?

1. Add the host to remotePatterns in next.config. Use the object form; leaving out search allows any query string: 2. On Next.js 15.3 or newer you can also pass a URL object, e.g. new URL('https://assets.example.com/account123/**'). On versions before 12.3, use images.domains instead. 3. Restart the dev server. next.config changes are not hot-reloaded.

Last checked against official docs on . Sources: Next.js docs: next-image-unconfigured-host.

Related errors

More Next.js errors and fixes →

Tools that help

  • Railway: Deploy backends and databases; new users get $20 credit.

Some links on this page are affiliate links: if you sign up or buy through them, FixStack may earn a commission at no extra cost to you. Learn more.

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy