Featured image of post Fix S3 UnableToCheckFileExistence 403 Error in Laravel

Fix S3 UnableToCheckFileExistence 403 Error in Laravel

Without s3:ListBucket in the IAM policy, S3 returns 403 for missing files, making [Flysystem](https://flysystem.thephpleague.com) throw UnableToCheckFileExistence. Adding the permission resolves it.

When using Laravel’s Storage to check if a file exists on S3, it throws League\Flysystem\UnableToCheckFileExistence with a 403 Forbidden error if the file doesn’t exist.

1
Storage::disk('s3')->exists('path/to.jpg');

Why 403 Instead of 404

When an AWS S3 user has s3:GetObject permission but lacks s3:ListBucket, the API returns 403 instead of 404 for non-existent files. This is AWS’s underlying behavior — Flysystem can’t distinguish between “no permission” and “file doesn’t exist.”

See this Laravel issue for related discussion.

Add s3:ListBucket Permission

After adding s3:ListBucket to the IAM Policy, checking for non-existent files will correctly return false.