How to Host a Website on AWS S3: The Step-by-Step Secret

A laptop displaying the AWS S3 console on a developer's desk.

How to Host a Website on AWS S3: The Step-by-Step Secret

A laptop displaying the AWS S3 console on a developer's desk.

Learning how to host a website on aws s3 step by step is one of the easiest wins in cloud computing. A static website, plain HTML, CSS and JavaScript with no server code, can live on Amazon S3 for pennies a month, and the whole setup takes about fifteen minutes.

Most tutorials stop at the basic setup, and that is where the trouble starts. The basic setup makes your bucket public and serves your site over plain HTTP, which is fine for a classroom demo and wrong for anything real. The secure setup uses CloudFront, and it is barely more work.

This guide covers both: the quick setup so you can see your site live today, and the secure CloudFront setup you should actually use. It also explains the Block Public Access warning, the HTTP-only endpoint, and the mistakes that catch beginners.

The short answer is to create an S3 bucket, upload your website files, enable static website hosting, and open the bucket website endpoint. For a real site, add CloudFront with Origin Access Control in front of the bucket, keep the bucket private, and serve the site over HTTPS with your own domain.

S3 static hosting suits portfolios, landing pages, documentation and small business sites. It does not suit anything that needs server code, logins or a database, because S3 serves files only and runs no code at all.

Key Takeaways

  • S3 hosts static websites only: HTML, CSS, JavaScript and images, with no server code or database.
  • The direct S3 website endpoint supports HTTP only, never HTTPS, which is why real sites add CloudFront.
  • Keep Block Public Access enabled and use CloudFront with Origin Access Control for the secure setup.
  • Bucket names must be globally unique across every AWS account in the world.
  • A static site on S3 costs very little, but you must watch storage, requests and data transfer charges.

A laptop screen showing the AWS S3 bucket list and upload view.
What S3 Static Hosting Is, and What It Is Not

Amazon S3 is object storage, not a web server. You create a bucket, which is a container for objects, and you upload files into it. When static website hosting is enabled, S3 serves those files to visitors like a simple web server would, starting with your index document.

A static website has no server-side code. It is HTML, CSS, JavaScript and images, and everything happens in the visitor’s browser. That covers portfolios, landing pages, blogs built with a static generator, documentation sites and small business pages.

It does not cover anything that needs a server: user logins, contact forms that send email, shopping carts, or databases. Those need compute, such as Lambda or a server, in front of or beside the storage. S3 alone cannot run code, and pretending otherwise is the most common beginner misunderstanding.

The appeal is price and simplicity. There is no server to patch, no operating system to maintain, and no minimum fee. You pay for storage per gigabyte-month, plus requests and data transfer, which for a small site adds up to very little.

What You Need Before You Start

You need an AWS account, a finished static website with at least an index.html file, and about fifteen minutes. A custom domain is optional for the first test, but you will want one for a real site, because the S3 endpoint address is long and forgettable.

Keep your website files in one folder on your computer, with index.html at the top level and any CSS, JavaScript and images in subfolders. Uploading is far easier when the folder is tidy before you start.

Step 1: Create an S3 Bucket

Sign in to the AWS Management Console, search for S3, and open the service. Click Create bucket, and give it a globally unique name, because bucket names live in a namespace shared by every AWS account in the world. A name such as my-first-website-123 works; my-bucket will always be taken.

Choose the region closest to your visitors, because it affects latency. Leave the remaining settings at their defaults for now, and click Create bucket. The bucket is private by default, which is exactly what you want for the secure setup later.

Do not turn off Block Public Access at this stage. AWS blocks public access by default for a reason, and the secure setup never needs to turn it off. The tutorials that tell you to disable it first are teaching the old, insecure method.

If you plan to use your own domain, name the bucket after the domain, such as www.example.com, because it makes the later domain setup simpler. It is not required for the first test, but it saves a step later.

A monitor showing AWS CloudFront distribution settings on a desk.
Step 2: Upload Files and Enable Static Website Hosting

Open your new bucket and click Upload. Add your index.html file and any CSS, JavaScript and image files, then click Upload. For a larger site, the AWS CLI is faster: one sync command uploads the whole folder, and you can repeat it whenever the site changes.

Next, enable static website hosting. Open the bucket, go to the Properties tab, scroll down to Static website hosting, and click Edit. Select Enable, choose Host a static website, and enter index.html as the Index document, plus error.html as the Error document if you have one.

Save the changes, and S3 will show you a bucket website endpoint, a long address ending in amazonaws.com. That endpoint is your site’s address for now, and you can open it in a browser to see the site. It works, but it serves over HTTP only, which is the limitation to fix next.

Test the site now, before adding CloudFront. Click through the pages, check the images load, and confirm the links work. Fixing a broken link is easier now than after the CDN is in front of it.

Step 3: The Secure Setup With CloudFront and OAC

CloudFront is Amazon’s content delivery network, and it sits in front of your bucket. Visitors connect to CloudFront, which fetches the files from S3 and serves them over HTTPS from the edge location nearest to each visitor. That makes the site faster and secure at the same time.

Create a CloudFront distribution and set the origin to your S3 bucket. When CloudFront asks about access, choose Origin Access Control, or OAC, which gives CloudFront permission to read the bucket while keeping the bucket private. This is the modern, secure method.

CloudFront will offer to update the bucket policy for you, adding a rule that allows only CloudFront to read the objects. Accept it, and keep Block Public Access enabled on the bucket. The bucket stays private, CloudFront serves the public, and nobody can bypass the CDN to reach the files directly.

Add your own domain and an HTTPS certificate in CloudFront if you have one, using AWS Certificate Manager, which issues free certificates. Point your domain’s DNS to the CloudFront distribution, wait for the changes to propagate, and your site is live on HTTPS under your own name.

A monitor displaying a newly launched website in a small office.
Going Live, Costs and Common Mistakes

Before launch, test the CloudFront address thoroughly: every page, every image, and every link. CloudFront caches content at the edge, so changes take time to appear unless you invalidate the cache, which you can do from the CloudFront console after each update.

Costs stay low for small sites. S3 charges for storage, requests and data transfer, and CloudFront charges for requests and data transfer out to the internet. A small site typically costs well under a dollar a month, but a sudden traffic spike or a large file can raise the bill, so set a billing alert.

The most common mistake is disabling Block Public Access and adding a public bucket policy, which exposes the bucket to the whole internet. Never do this for a production site, and never store passwords, private documents or API keys in a website bucket, even a private one.

Another common mistake is uploading files with the wrong content type, which makes browsers download a page instead of showing it. S3 usually detects the type correctly, but check the metadata on uploaded files if a page behaves strangely.

S3 Hosting: Quick Setup vs Secure Setup

FactorQuick setupSecure setup with CloudFront
Bucket accessPublic, Block Public Access offPrivate, Block Public Access on
ProtocolHTTP onlyHTTPS with your own domain
SpeedSingle regionEdge locations worldwide
SecurityAnyone can read the bucketOnly CloudFront can read it
CostSlightly lowerSlightly higher, still very low
Use forTesting and learningAny real website

S3 Website Launch Checklist

Run through this checklist before you share your site with anyone, because the mistakes that matter are all made before launch.

  1. Create the bucket with a globally unique name in the region closest to your visitors.
  2. Upload index.html and all assets, and confirm the site loads on the S3 endpoint.
  3. Keep Block Public Access enabled and do not add a public bucket policy.
  4. Create a CloudFront distribution with Origin Access Control for the bucket.
  5. Add your domain and a free HTTPS certificate from Certificate Manager.
  6. Test every page, image and link through the CloudFront address.
  7. Set a billing alert so a traffic spike cannot surprise you.

Frequently Asked Questions

Can I host a website on AWS S3 for free?

Almost. S3 has a free tier for new accounts, and a small static site typically costs well under a dollar a month after that. You pay for storage, requests and data transfer, so set a billing alert and keep an eye on the costs as traffic grows.

Why is my S3 website only available over HTTP?

The S3 website endpoint supports HTTP only, because S3 cannot serve a certificate for its own endpoint address. Add CloudFront in front of the bucket to serve the site over HTTPS, with your own domain name and a free certificate from Certificate Manager.

Do I need to make my S3 bucket public to host a website?

No, not with the secure setup. Keep Block Public Access enabled and use CloudFront with Origin Access Control, which lets CloudFront read the bucket while keeping it private. Making the bucket public is the old method, and it exposes your files to the whole internet.

Can S3 host a WordPress or dynamic website?

No. S3 serves static files only and runs no server code, so it cannot host WordPress, logins, contact forms that send email, or anything needing a database. Static sites, portfolios, landing pages and documentation are the right fit for S3 hosting.

How do I update my website after deploying to S3?

Upload the changed files to the bucket again, or use the AWS CLI sync command to upload the whole folder. If you use CloudFront, invalidate the cached files afterwards, or the old versions will keep showing until the cache expires.

What is the difference between S3 and CloudFront?

S3 is where your files live, and CloudFront is the delivery network that serves them to visitors quickly and securely over HTTPS. S3 alone can host a site over HTTP, while CloudFront adds HTTPS, your own domain, and edge caching close to your visitors.

Conclusion

Hosting a website on AWS S3 is genuinely simple: a bucket, some files, and static hosting enabled. The part that matters is the ten minutes after that, when you add CloudFront with Origin Access Control and keep the bucket private.

Do that, and you have a fast, secure, HTTPS website on your own domain for pennies a month, with no server to maintain. Skip it, and you have a demo on plain HTTP with a public bucket. The difference is small in effort and large in every other way.

For more on this topic, see our guides to Amazon S3 production mistakes to avoid, what Amazon S3 really costs, common Amazon S3 mistakes when securing storage and MinIO alternatives for S3-compatible storage.

on this page