Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bukxy's avatar
Level 1

AWS S3 Error executing "HeadObject" / AWS HTTP error: Client error

Hello, I want use S3, but i have some problems in localhost I started with an arror where i need to replace in

vendor/flysystem-aws-s3-v3/src/AwsS3Adapter.php
use Aws\S3Client;
by
use Aws\S3\S3Client;

And now i have this error : (i replace the url cause it's my first day)

Error executing "HeadObject" on "HTTPLinkOfMybucket/images/1/CYnewElzWlQgV0wKoBeo9d98f0pD9vWNCCtAwqJY.png"; AWS HTTP error: Client error: `HEAD HTTPLinkOfMybucket/images/1/CYnewElzWlQgV0wKoBeo9d98f0pD9vWNCCtAwqJY.png` resulted in a `404 Not Found` response NotFound (client): 404 Not Found (Request-ID: QBSWZ5RXFZ2F7Y51) -

i filled out AWS config in my .env

I saw something too where we need too add this in my bucket, but none change.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::472492315669:user/rs"
            },
            "Action": [
                "s3:DeleteObject",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::rank-serv/*"
        }
    ]
}

In my controller i tested :

Storage::disk('s3')->put('images', $req->file('banner'))
or
$req->file('banner')->store('images/'.$req->user()->id, 's3')
or
$req->file('banner')->storeAs('images/', $req->user()->id, 's3')

Any idea ?

0 likes
8 replies
martinbean's avatar

@bukxy Something is trying to get the details of an object that doesn’t exist in S3. So check the path and bucket name.

If it was a permissions (IAM) error, then you would have gotten a 403 error. But you’re getting a 404 error instead.

bukxy's avatar
Level 1

@martinbean my user "rs" have AmazonS3FullAccess perm, i watched videos / posts and i did what they did. That's why i'm a little lost ^^

(.env)
AWS_ACCESS_KEY_ID=user_access_id
AWS_SECRET_ACCESS_KEY=user_secret
AWS_DEFAULT_REGION=eu-west-3
AWS_BUCKET=rank-serv
AWS_USE_PATH_STYLE_ENDPOINT=false

i created many users and buckets too see what happend and same result

martinbean's avatar

@bukxy Again, 404 means the object path is wrong. It’s nothing to do with permissions.

bukxy's avatar
Level 1

@martinbean ok sry i read backwards ^^, so the problem come from the path or name of my bucket,

i recreate my bucket and remake all steps. so is not my bucket name,

What do you mean by the path ? the urls of my errors are :

http :// rank-server .s3 . eu-west-3. amazonaws. com/images/1/s6bbDxV4AyRBuV1abGo95XMf5xO3tEZu7xMFvv5z.png

so that means he can't find rank-server or the images folder ?

And if it's the path how can i fix that ?

martinbean's avatar

@bukxy You’re getting a 404, which means you’re specifying a path that doesn’t resolve to an object in S3. So either your bucket, region, or file path is wrong.

bukxy's avatar
Level 1

@martinbean ok so i tested with many others buckets / regions, and i'ts same:

My bucket have the default config.

Name : rank-server
AWS Region : EU (Paris) eu-west-3
Access : Bucket and objects not public
Creation date : December 17, 2021, 14:25:29 (UTC+01:00)

What i missed for getting this error ? I already search many docs and posts with this error.

Sorry i'm novice ^^

bukxy's avatar
Level 1

@martinbean hello, ok my bucket was created but the problem is only when i want to store my file ( already tested with ->store() and ->storeAs() )

I can only store when i upload manually the file in my bucket and if the file name who i upload is the same of my file in my bucket. I don't understand why

ElMarkesDeSade's avatar

Have you had any luck solving this problem? I'm facing the same issue. I'm able to download files from my S3 bucket flawlessly . The problem comes when I try to upload a file I get the same error:

Error executing "HeadObject" on [my-bucket] 404 Not Found response NotFound (client): 404 Not Found

Please or to participate in this conversation.