close

[Solved] AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found Error Occurs?

Today I get the following error AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found in python.

How To Solve AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found Error ?

  1. How To Solve AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found Error ?

    To Solve AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found Error Yet another possibly is that you entered an incorrect endpoint_url parameter when creating your S3 resource.

  2. AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found

    To Solve AWS BOTO3 S3 python – An error occurred (404) when calling the HeadObject operation: Not Found Error Yet another possibly is that you entered an incorrect endpoint_url parameter when creating your S3 resource.

Solution 1

I had the same issue recently. You are probably misspelling the path and folder name. In my case, for example, I was messing up with the ‘/’.

To fix it, make sure the variables you are using as arguments for the function contains the correct names of the directories, folders and files as it is in S3. Also, make sure you put the ‘/’ in the correct places in the correct variables. For instance, in my case I found that:

  • bucket name: bucket_name (with no ‘/’ in the end, and no ‘s3://’)
  • directory name: folder1/folder2/file_name (with no ‘/’ in the beginning)

I hope it helps you and others to get around this error easily.

Solution 2

Yet another possibly is that you entered an incorrect endpoint_url parameter when creating your S3 resource.

For future users, create your resource like this:

s3 = boto3.resource(
  's3',
  region_name=[your region, e.g. eu-central-1],
  aws_access_key_id=[your access key],
  aws_secret_access_key=[your secret key]
)

In the above, it is possible to pass an endpoint_url, as I erroneously did (I later found out that I had accidentally passed the endpoint URL to a different AWS service).

If you are using AWS CLI in order to authenticate, you can omit the region_nameaws_access_key, and aws_secret_access_key parameters, like so:

s3 = boto3.resource('s3')

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read