I created Amazon aws s3 bucket i want to get files but i says 404 error

Certified Associate Developer

My base url : 

Base URL

https://testbucket.s3.ap-south-1.amazonaws.com/   (where s3 testbucket is bucket name)

relative path : /myfiles/star.pdf ( where /myfiles is folder)

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I copied your question into Google Gemini and got this:

    Okay, a 404 "Not Found" error when trying to access an S3 object via its URL usually points to one of a few common issues, primarily related to permissions or the exact object path/name.

    Let's troubleshoot step-by-step:

    1. Verify Object Existence and Exact Path:

      • Go to the AWS S3 console.
      • Navigate to your bucket testbucket in the ap-south-1 (Asia Pacific - Mumbai) region.
      • Inside the bucket, do you see a folder named exactly myfiles (case-sensitive)?
      • Inside that myfiles folder, do you see a file named exactly star.pdf (case-sensitive)?
      • Common Mistake: Sometimes uploads might create nested folders unexpectedly, or there might be slight typos or case differences (e.g., MyFiles instead of myfiles, or Star.pdf instead of star.pdf). Double-check the precise name and location. The full object key must be myfiles/star.pdf.
    2. Check Permissions (Most Likely Cause):

      • By default, S3 buckets and objects are private. Accessing an object directly via its URL requires it to be publicly readable.
      • Bucket Level - Block Public Access:
        • In the S3 console, go to your testbucket.
        • Click on the "Permissions" tab.
        • Look at the "Block public access (bucket settings)" section. For public URL access to work, you generally need to uncheck at least the options related to blocking public access via ACLs (Access Control Lists). Specifically, ensure "Block public access to buckets and objects granted through new access control lists (ACLs)" and "Block public access to buckets and objects granted through any access control lists (ACLs)"1 are OFF (unchecked). Be very careful when changing these settings, as they impact security. Only allow public access if you intend the file to be accessible by anyone on the internet. If you use a Bucket Policy instead of ACLs, you'd adjust the policy-related blocks accordingly.
      • Object Level - Access Control List (ACL):
        • Navigate to the object itself (myfiles/star.pdf) in the S3 console.
        • Click on the object.
        • Go to its "Permissions" tab.
        • Look at the "Access Control List (ACL)" section.
        • Under "Everyone (public access)", does it have "Read" permission granted? If not, click "Edit", check the "Read" box under the "Objects" column for the "Everyone (public access)" grantee, acknowledge the warning about making it public, and save the changes. This step is only possible if the Bucket's "Block Public Access" settings (from the previous point) allow public ACLs.
      • Bucket Policy (Alternative/Additional Check):
        • Check the "Bucket Policy" section under the bucket's "Permissions" tab. Is there a policy in place? If so, does it explicitly Allow the s3:GetObject action for Principal: "*" (everyone) on the resource arn:aws:s3:::testbucket/myfiles/* or arn:aws:s3:::testbucket/myfiles/star.pdf? Or, conversely, does it Deny access? A Deny statement in a bucket policy will override ACL permissions.
    3. Verify the URL Format:

      • The URL format you are using is the "virtual-hosted style", which is generally preferred:https://<bucket-name>.s3.<region>.amazonaws.com/<object-key> testbucket.s3.ap-south-1.amazonaws.com/.../star.pdf
      • This looks correct based on your description. Double-check that the bucket name (testbucket) and region (ap-south-1) in the URL exactly match your bucket's configuration.

    In summary, the most likely reasons for the 404 are:

    • The object myfiles/star.pdf doesn't actually exist at that exact path (check case sensitivity and folder structure).
    • The object (or the bucket) does not have public read permissions configured correctly (check Block Public Access settings AND the object's ACL or the Bucket Policy).

    Go through these checks in the AWS console, paying close attention to exact names and permission settings. Remember the security implications of making objects public.