Next.js Image Not Working in Production? Find the Cause by Its Error
A broken next/image in production is usually a rejected request with a specific sentence in the response. This guide maps each status and sentence to its cause, including the Next.js 16 defaults that older advice misses, and every case was reproduced in a test project.
Ali RehmanFreelance Web Developer
On this page 16 sections
The page loads and the layout is right, but where the picture should be there is an empty box or the alt text. It worked on your machine. The build log shows nothing wrong.
/_next/image and read two things: the status code and the short sentence in the response. Next.js rejects an image with a specific sentence, and each sentence has only a few causes. Find that sentence in the table below, change one thing, and test again with a production build, because several of these mistakes raise an error only in development.Every behavior described here was reproduced on 13 November 2026 in a small test project running Next.js 16.3.5: 41 checks across six builds. The method and its limits are at the end. Version 16 changed several image defaults, so advice written for versions 14 and 15 misses some of these causes.
Why it fails in production without an error
In development, next/image checks its input and stops with a named error, such as a hostname that is not configured. In the 16.3.5 source, the image loader runs those checks only when the app is not in production mode. In production the component just writes the image address into the page, and the server decides later whether to answer it.
The test showed this directly. A page with an image from an unconfigured host built without complaint. In production the page returned status 200 and only the image request failed, with status 400. In development the same page returned status 500 with the named error. A missing width behaved the same way: an error in development, and in production an image tag with no width or height, which shifts the layout but does not hide the picture.
So “it works locally” usually means one of three things. The production data is different: another image host, a query string, a file that is not there. The production server is different: a static export, a standalone build, another hosting platform. Or a cache is still serving an old result. The sections below follow that order.

Start with the image request, not the code
- 1Open the broken page on the live site and open the browser’s developer tools.
- 2Go to the Network panel, filter by images and reload the page.
- 3Find the request whose address starts with
/_next/image?url=. Note its status code. - 4Open the Response tab for that request. A rejected image returns one plain sentence instead of a picture.
- 5Copy the value after
url=, decode it and open that original address in a new tab.
The last step splits the problem in two. If the original address does not load either, the file or the hosting is the problem (sections 3 and 6). If the original loads and only the /_next/image version fails, the image configuration is rejecting it (sections 1 and 2).
What the /_next/image request returned
→ section: most likely cause
400 "url" parameter is not allowed
→ 1: host, path, query string or local IP
400 "w" parameter (width) of N is not allowed
→ 2: width is not a configured size
400 "q" parameter (quality) of N is not allowed
→ 2: quality is not in images.qualities
400 The requested resource isn't a valid image.
→ 3: file missing, or the URL returned HTML
400 "url" parameter is valid but image type is not allowed
→ 3: an SVG reached the optimizer
404/508 "url" parameter is valid but upstream response is invalid
→ 4: the remote server failed or redirected
Not found for /_next/image itself
→ 5: static export, no image server
404 for the original file as well
→ 6: public folder missing on the server
200, but it is the old picture
→ 7: optimizer cache, 4 hours by default
402 on Vercel
→ 8: the plan's image limit was reached
Sentences are from Next.js 16.3.5.1. 400: “url” parameter is not allowed
This sentence means the address is not on the allowlist. The test produced exactly the same sentence for four different reasons, so the sentence alone does not tell you which one you have.
- The remote host is not in
remotePatterns. No external host is allowed until you list it. In production this usually happens when the live CMS or storage bucket uses a different hostname from the one you developed against, or when editors paste image addresses from other sites. The unconfigured host message shows the pattern format. The olderimages.domainssetting is deprecated. - A local path is outside
localPatterns. Once you definelocalPatterns, only matching paths can be optimized. In the test, a file under/other/opened fine at its own address but returned 400 through the optimizer, because only/photos/**was listed. This site uses such an allowlist, so a new image folder needs a new pattern before its pictures load. See the localPatterns message. - A local image has a query string. New in version 16: an address such as
/photos/desk.jpg?v=2is rejected unless a local pattern lists that exactsearchvalue. The test returned 400 by default and 200 after addingsearch: "?v=2". The source also contains a component-level error for this case that is not limited to development; the test exercised the request, not that error. - The remote host resolves to a local or private IP address. Also new in version 16. In the test the host matched
remotePatterns, but it was127.0.0.1, and the optimizer still answered 400 with the same sentence. Only the server log gave the reason: hostname resolved to private IP. This affects a headless CMS onlocalhost, a service name inside Docker and hosts on a private network.
For the private IP case, the cleanest fix is to give the image host a public address. The version 16 upgrade guide describes dangerouslyAllowLocalIP as an option for private networks only, because it lets the image endpoint fetch addresses inside your network. Do not turn it on for a public server to make an error go away.
// next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{ protocol: "https", hostname: "cdn.example.com", pathname: "/uploads/**", search: "" },
],
localPatterns: [
{ pathname: "/photos/**", search: "" },
{ pathname: "/photos/**", search: "?v=2" },
],
},
};
export default nextConfig;Rebuild and redeploy after changing the image configuration. The test rebuilt the project for every change, and for standalone builds the documentation states that the configuration is read during the build.
2. 400 for a width or a quality value
The optimizer accepts only the widths in deviceSizes and imageSizes. In the test, w=500 was rejected, and so was w=16, because version 16 removed 16 from the default sizes. The component only writes allowed widths, so this error comes from addresses built by hand: a CSS background, an Open Graph tag, an email template or another application pointing at your /_next/image endpoint.
Quality works the same way, with one difference. In version 16 the default list is [75], and a direct request with q=85 returned 400. The component does not fail, though. It quietly uses the closest allowed value. In the test, quality={85} rendered an address ending in q=75, and it became q=85 only after adding qualities: [75, 85] to the configuration.
So after an upgrade the symptom is often not a missing image. It is a quality prop that seems to do nothing, or images that look slightly softer than before. List every quality you use in images.qualities.
3. “The requested resource isn’t a valid image”
The address was allowed, the optimizer fetched it, and what came back was not a picture. The test produced this sentence in three ways.
- The file does not exist. A path with no file behind it returned status 400 with this sentence, not 404, because the optimizer received the application’s own not-found page. Check the path and the spelling. Linux servers treat
Photo.JPGandphoto.jpgas different files, while Windows and macOS development machines usually do not. The test ran on Windows, so that case was not reproduced here. - The
publicfolder is not on the server. This is the standalone case in section 6, and it returned the same sentence. - The remote address returned a web page. A remote URL that answered with HTML was rejected with this sentence. In practice that is a login page, hotlink protection, an expired signed link or a bot challenge in front of the image host.
SVG files have their own sentence: “url” parameter is valid but image type is not allowed. The optimizer does not serve SVG by default. The component avoids the problem when the address ends in .svg by pointing at the file directly, which the test confirmed. The error appears when an SVG has an address without that ending, such as a CMS media link, or when the address was built by hand. The Image component reference recommends the unoptimized prop for those images. dangerouslyAllowSVG exists, but the reference pairs it with extra security headers for a reason.
4. 404 or 508: the remote server failed
The sentence “url” parameter is valid but upstream response is invalid means your configuration allowed the address and the remote server did not deliver. In the test, a remote 404 was passed through as 404. A redirect chain worked up to three redirects, and the fourth returned status 508, because version 16 limits redirects to three where earlier versions followed them without a limit.
The optimizer source also contains a 504 for a remote server that does not answer in time and a 413 for a response over the size limit. The test did not exercise those two.
Fix this at the source. Use the final address instead of one that redirects, correct or re-upload the missing file, and raise maximumRedirects only if you know why the chain is that long. The reference notes that redirect targets are not checked against remotePatterns again.
5. Static export: the build passes and the images break
This was the least expected result of the test. With output: "export" and the default image loader, next build finished successfully and printed no warning about images. The exported HTML still pointed every image at /_next/image?url=…, and the out folder contains no such endpoint, because a static export has no server to resize anything. On a static host those images cannot load.
The same configuration in development stopped immediately with Image Optimization using the default loader is not compatible with { output: 'export' }. The static exports guide lists image optimization with the default loader as unsupported and says these features produce an error with next dev. If you only ever run the build, for example in a deployment pipeline, you never see it.
There are two fixes, both described on the export image message page. Set images: { unoptimized: true }; in the test the image then pointed at the original file, and that file was copied into the export. Or configure a custom loader for an image service. With unoptimized, visitors download your original files, so resize and compress them before they go into public.

6. Standalone and Docker: the public folder is not copied
The output documentation says it plainly: the minimal standalone server does not copy the public or .next/static folders by default. In the test, the standalone server started and served pages, the original image address returned 404, and the optimizer returned the “isn’t a valid image” sentence from section 3. After copying both folders, the file returned 200 and the optimized image loaded.
# after next build, from the project folder
cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/In a Dockerfile the same two folders need their own copy steps. They belong next to server.js. In the test project that file sat in a nested folder inside standalone, because the project was part of a larger repository, so check where yours is before copying.
7. The image loads, but it is the old one
Optimized images are stored on the server under .next/cache/images and sent with a cache lifetime. Version 16 raised the default minimum from 60 seconds to 4 hours. In the test, every optimized response carried Cache-Control: public, max-age=14400, must-revalidate.
The test then replaced the file at the same path. The original address served the new picture immediately. The optimized address that had already been requested kept serving the old picture from cache. A width that had not been requested yet was generated from the new file. In a real site that means different screen sizes can show different versions of the same image, which is confusing to debug.
- Give the new picture a new file name. This is the simplest fix and works on every host.
- Import the file instead of using a path. The reference explains that a static import hashes the file contents, so a changed file gets a new address.
- Add a version to the address, such as
?v=2, and list that value inlocalPatternsas shown in section 1. - Lower
minimumCacheTTLif your images change often. Shorter lifetimes mean more re-processing. - Delete the cached files under
.next/cache/imageson the server. The reference states there is no built-in way to invalidate this cache.
Browsers and any CDN in front of the site keep their own copy for the same lifetime. Test in a private window before deciding the fix did not work.
8. When the hosting platform’s image service is the cause
On Vercel, images are optimized by the platform and counted against the plan. The limits and pricing page says that once a Hobby project exceeds its limits, new images fail to optimize and return status 402, while images that were already optimized keep working. If older pictures load, new ones show only alt text and the status is 402, look at usage before you look at code.
For other hosts, the deployment documentation separates a Node.js server or Docker container, which support all features, from platform integrations whose feature support may vary. The self-hosting guide states that image optimization works without extra configuration under next start. If a platform runs your app another way, read its own notes on images. My hosting guide covers what to ask a host before you commit.
Checks that are not next/image at all
If the image request returns 200 and you still see nothing, the picture arrived and something on the page is hiding it.
- A
fillimage inside a parent with no size. The reference requires the parent to setpositionto relative, fixed or absolute. If that parent also has no height, the image has zero height. - Missing
widthandheight. In the production test this rendered the picture without those attributes. The image shows, but the layout jumps as it loads. - A Content Security Policy that does not allow the image host. The browser console reports the blocked address and no request is sent.
- An
http://image on anhttps://page. Browsers upgrade or block insecure images on secure pages.
The last two are general browser behavior and were not part of the test. If the pictures load but the page is slow, the Next.js performance guide covers sizes and preloading, and why a website is slow covers the wider causes. A WordPress site with the same symptom has different causes; those are in WordPress images not showing.
Fixes that create new problems
- Allowing every host. A pattern that matches any hostname makes the error disappear and lets anyone use your server to fetch and resize images from anywhere. The reference warns against wide patterns for that reason.
- Turning on
dangerouslyAllowLocalIPon a public server. It is meant for private networks. - Setting
unoptimized: truefor the whole site. Every visitor then downloads the original files. Use it per image for SVGs and tiny icons, or site-wide only for a static export. - Turning on
dangerouslyAllowSVGwithout the security headers the reference lists beside it. - Dropping
minimumCacheTTLto a few seconds. The upgrade guide raised the default because frequent re-processing costs CPU time and money.
Verify the fix the way production runs
- 1Run
next buildand thennext starton your machine. Do not rely onnext dev; it hides the production behavior described above. - 2Open the page with the Network panel and check that every
/_next/imagerequest returns 200 with an image content type. - 3Test with production data: an image address taken from the live CMS, not a file that exists only on your machine.
- 4Request the same image twice and look at the
x-nextjs-cacheresponse header. In the test it read MISS on the first request and HIT on the second. - 5After deploying, check in a private window on a phone and on a desktop, because they request different widths.
- 6Write down the sentence you saw and the one change that fixed it.
When to hand it to a developer
Get help when images come from many hosts that you do not control, when the fix involves a custom loader or an image CDN, when you need to decide whether a private-network exception is safe, or when remote images fail only some of the time. Those cases need someone reading server logs and configuration together.
Send the page address, the full failing /_next/image address, the status code and the sentence in the response, the Next.js version, where the site is hosted and the images part of your configuration. Do not send passwords or API keys. This kind of diagnosis is part of my Next.js development service, and you can send the details here. If you are choosing someone else for the work, the guide on how to hire a Next.js developer lists what to ask.
Frequently asked questions
Why do Next.js images work locally but not in production?
Development raises named errors for image mistakes, and production does not. The production page renders and only the image request fails. The usual differences are the image host or addresses used by live data, a static export or standalone build that has no image server or no public folder, a hosting limit, or a cached result. Read the status and sentence of the /_next/image request to tell them apart.
What does “url parameter is not allowed” mean in Next.js?
The image address is not on the allowlist. Either the remote host is missing from remotePatterns, a local path is outside localPatterns, a local address has a query string that is not listed, or the remote host resolves to a local or private IP address. Version 16 added the last two.
Why did images break after upgrading to Next.js 16?
Version 16 changed five image defaults. Only quality 75 is allowed unless you list others. Local images with query strings need a matching pattern. Remote hosts on local IP addresses are blocked. At most three redirects are followed. The size 16 was removed from the default sizes. The default cache lifetime also rose to 4 hours, so replaced pictures take longer to appear.
How do I use next/image with a static export?
Set images: { unoptimized: true } or configure a custom loader for an image service. Without one of these the build still succeeds, but the exported pages request /_next/image, which does not exist on a static host.
Why is my updated image still showing the old version?
The optimized copy is cached on the server for at least 4 hours by default, and the browser caches it for the same time. Give the new picture a new file name, import it so the address includes a content hash, or delete .next/cache/images on the server.
Should I just set unoptimized to make the error go away?
Only when optimization is not useful or not possible: SVGs, very small images, files that are already the right size, or a static export. For everything else it hides a configuration problem and sends larger files to every visitor.
Sources, test and review scope
The sentences, status codes and development-only checks were read from the Next.js 16.3.5 source: the image optimizer, the image loader and the component’s property checks. Defaults and recommended fixes come from the Image component reference, the version 16 upgrade guide and the other documentation pages linked above, all checked on 13 November 2026.
The behavior was then reproduced in a new App Router project with three pages, built with Next.js 16.3.5, React 19.2.4 and Turbopack on Node.js 24. It was built once for each of six configurations and served on a local address with next start, with next dev for the development comparisons and node server.js for the standalone step. A small local server stood in for a remote image host. Across 40 recorded requests and file checks, all 41 expectations matched, including these:
- 1With no image configuration, a local JPEG was converted to WebP at quality 75 and cached for 14,400 seconds; the second request was a cache hit.
- 2Quality 85, width 500 and width 16 were each rejected with their own sentence.
- 3A local query string, an unlisted remote host, a path outside
localPatternsand a listed host on a local IP address all returned the same “url” sentence. - 4A missing file and a remote HTML page both returned “isn’t a valid image”; an SVG returned “image type is not allowed”.
- 5Three redirects were followed and four returned 508; a remote 404 was passed through.
- 6A static export built successfully with image addresses that the export does not contain, and raised the named error only in development.
- 7A standalone server returned 404 for a public image until
publicand.next/staticwere copied beside it. - 8A file replaced at the same path kept its old optimized copy while the original address served the new one.
Limits: one Windows machine with a Node.js server. The test did not cover Vercel’s or any other host’s image service, custom loaders, a CDN in front of the app, Docker itself, case-sensitive file systems, AVIF, animated images or slow networks. The test pictures were generated gradients, not real photographs. Prepared with AI-assisted research and testing; I reviewed the results against the linked sources before publishing.
Written by
Ali Rehman - Freelance Web Developer
I work on WordPress websites, practical fixes and scoped web applications. Read my background and skill scope, or send a project brief to discuss a written plan and quote - start here.
More articles by Ali Rehman →