How to fix AWS S3 "Access Denied" on public bucket

AdSense - In Article Top

If you are trying to access a file uploaded to your AWS S3 bucket via the browser URL, but you see an "Access Denied" or 403 Forbidden XML error, it means your bucket permissions are not set to public.

By default, all S3 buckets are private for security reasons. To make them public (for a website or image hosting), you need to do two things.

Step 1: Uncheck "Block Public Access" 🔓

1. Go to your S3 Console and open your bucket.

2. Click on the Permissions tab.

3. Scroll down to Block public access (bucket settings) and click Edit.

4. Uncheck "Block all public access".

5. Click Save Changes and type "confirm" in the box.

AWS S3 Block Public Access Settings
AdSense - In Article Middle

Step 2: Add Bucket Policy (The Main Fix) 📝

Even after unblocking, you need to explicitly tell AWS to allow anyone to read the files. We do this using a JSON policy.

1. Still in the Permissions tab, scroll down to Bucket policy.

2. Click Edit and paste the following JSON code:


{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        }
    ]
}
            

⚠️ Important: Replace YOUR-BUCKET-NAME with the actual name of your bucket (e.g., vishtech-images/*).

Click Save changes. Now your files should be accessible publicly!


Did this fix your issue? Check out more cloud solutions in the sidebar.