Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»S3 & Cloudfront: 404 Error on Page Reload (Resolved)

    S3 & Cloudfront: 404 Error on Page Reload (Resolved)

    RahulBy RahulJuly 15, 20222 Mins Read

    I have recently deployed a published Node.js application via Amazon S3 static website hosting. After deployment, I noticed that we get the 404 error message while refreshing the pages. After a few searching, I got the reason behind it. I found that the application required a special configuration for routing like .htaccess in Apache servers. But here is the issue, we can’t use the .htaccess file with S3 static website hosting.

    In this tutorial, we will discuss solving this issue with the options provides under the S3 configuration. Also, provide you with instructions to fix this issue for the users using the Cloudfront.

    Amazon S3 (Static Website Hosting)

    Amazon S3 uses index.html as default index file. If your application is hosted on Amazon s3 static website hosting. You just need to configure index.html in the Error document.

    Go to the application S3 bucket -> Properties -> Static website hosting and set the Error document as showing in below image:

    React Handle 404 Error with CloudFront

    Amazon CloudFront

    In the case of using Amazon Cloudfront with an s3 bucket, You also need to configure the Error pages in Cloudfront.

    Edit the Cloudfront -> Error pages. Now create a custom error response for 404 to index.html. You can also do the same for the 403 error code.

    React Handle 404 Error with S3 Bucket

    Conclusion

    This blog post helped you to resolve the 404 error with Amazon S3 and Cloudfront.

    Amazon s3 Cloudfront Error Code 404
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleRunning “npm start” with PM2
    Next Article How to Install Grunt on Ubuntu 22.04 & 20.04

    Related Posts

    How to Import GPG Keys on Ubuntu & Debian (without apt-key)

    2 Mins Read

    Running a Cron job every Sunday (Weekly)

    2 Mins Read

    Scheduling a Python Script with Crontab

    2 Mins Read

    Running cron job every 12 hours (twice a day)

    Updated:August 2, 20221 Min Read

    (Resolved) Key is stored in legacy trusted.gpg Keyring

    Updated:August 9, 20222 Mins Read

    How to list all collections in MongoDB database

    1 Min Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Import GPG Keys on Ubuntu & Debian (without apt-key)
    • How To Install Google Chrome On macOS
    • How to Install Minecraft on Ubuntu 22.04 & 20.04
    • Running a Cron job every Sunday (Weekly)
    • Running Multiple Commands At Once in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.