2023-07-05 15:11:16 +02:00
---
title: '`next/image` Un-configured Host'
---
2020-10-27 22:55:21 +01:00
2023-07-05 15:11:16 +02:00
## Why This Error Occurred
2020-10-27 22:55:21 +01:00
2023-05-04 00:10:57 +02:00
One of your pages that leverages the `next/image` component, passed a `src` value that uses a hostname in the URL that isn't defined in the `images.remotePatterns` in `next.config.js`.
2020-10-27 22:55:21 +01:00
2023-07-05 15:11:16 +02:00
## Possible Ways to Fix It
2020-10-27 22:55:21 +01:00
2022-10-06 18:51:41 +02:00
Add the protocol, hostname, port, and pathname to the `images.remotePatterns` config in `next.config.js`:
2023-07-05 15:11:16 +02:00
```js filename="next.config.js"
2022-10-06 18:51:41 +02:00
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
2023-05-04 00:10:57 +02:00
hostname: 'assets.example.com',
2022-10-06 18:51:41 +02:00
port: '',
pathname: '/account123/**',
},
],
},
}
```
2023-05-04 00:10:57 +02:00
#### Fixing older versions of Next.js
2020-10-27 22:55:21 +01:00
2023-05-04 00:10:57 +02:00
<details>
<summary>Using Next.js prior to 12.3.0?</summary>
2023-07-05 15:11:16 +02:00
Older versions of Next.js can configure `images.domains` instead:
```js filename="next.config.js"
module.exports = {
2020-10-27 22:55:21 +01:00
images: {
domains: ['assets.example.com'],
},
2023-07-05 15:11:16 +02:00
}
```
2023-05-04 00:10:57 +02:00
</details>
2020-10-27 22:55:21 +01:00
2023-07-05 15:11:16 +02:00
## Useful Links
2020-10-27 22:55:21 +01:00
2023-07-05 15:11:16 +02:00
- [Image Optimization Documentation](/docs/pages/building-your-application/optimizing/images)
- [Remote Patterns Documentation](/docs/pages/api-reference/components/image#remotepatterns)