Learn how to troubleshoot 400 and 404 errors while accessing the image through ImageKit.io
When ImageKit gets an error while trying to fetch the original image from your external origin, it responds with
404status code along with a generic "Not Found" message like below:
To help you troubleshot the error, the response is accompanied by an
ik-errorheader, which expounds more detail about the nature of the error.
The value of
ERROR_CODE - ERROR_MESSAGE
For example, when you try to access an image from your AWS S3 bucket that doesn't exist, you will receive a
404status code with an
ik-errorheader as follows:
ENOENT - No file was found on S3 at the specified path
You can use browser developer tools to inspect the response header and read the error message. For example, if we try to access the below non-existing image:
ImageKit returns a blank white page with a
Not Foundmessage, but you can inspect the
ik-errorheader from the developer tools (Ctrl + Shift + i for Chrome) like this
ik-error has a value composed of an error code and an error message
This helps you identify that the error is caused because the file name specified in the URL does not exist on the origin. The origin, in this case, is an S3 bucket, but it can be any origin that ImageKit supports.
Similarly, the header may consist of one of the other possible error codes and an accompanying message:
It means the file does not exist at the given path on the origin server or object storage. Check the origin server associated with the URL-endpoint and ensure that the file exists.
Invalid or expired authentication credentials for the corresponding origin. In this case, you should check the credentials provided in the ImageKit dashboard while configuring origin and ensure that ImageKit.io has the necessary permission to access the file. In the case of web server origin, you should check firewall settings and whitelist our servers. In the case of object storage, you should ensure that the configured credential has read access.
Refer to limits to understand more about the reason for the error. The response status is
The external origin refused to connect. This usually happens if your origin web server has some maximum connection limit, or a firewall has blocked our request. You should check firewall settings and whitelist our servers.
The exact nature of the error could not be identified. This is rare, in this case, contact us at [email protected]