
Have you ever built a website, completed the design, fixed all the bugs, and finally decided to make it live? You deploy it, and everything works. But when you share the link with someone, it looks something like your-project.pages.dev or your-project.vercel.app.
There is nothing wrong with these URLs, especially when you are testing a project. But if you want to showcase your portfolio, launch a blog, or build your personal brand, having your own domain looks much more professional.
The good news is that you can host a website for free, connect a custom domain, and get HTTPS without paying a monthly hosting fee. You generally still need to purchase the domain name itself, unless you already own one.
For example, you could host a personal portfolio on a free hosting plan and connect a domain such as yourname.dev. You could also publish a technical blog without paying for a traditional hosting server.
In this guide, I will explain how free website hosting works, which platforms you can use, how to connect your domain, and how to fix common DNS problems.
1. Can You Really Host a Website for Free With a Custom Domain?
Yes. Several hosting platforms offer free plans that support custom domains and HTTPS for eligible projects.
Some popular options include:
Cloudflare Pages for static websites and supported frontend frameworks.
GitHub Pages for websites published from GitHub repositories.
Vercel for frontend applications and supported frameworks.
Netlify for static websites and frontend projects.
Each platform has its own limits, supported features, and usage policies. Check the current plan details before choosing one, especially if you intend to use the website commercially.
What is actually free?
Component | Can it be free? |
|---|---|
Static website hosting | Yes |
Default hosting subdomain | Yes |
Connecting a domain you already own | Often yes |
HTTPS certificate | Usually included |
Git-based deployment | Usually included |
Domain registration | Generally paid |
Backend API hosting | Sometimes, depending on the provider |
Database hosting | Sometimes, depending on the provider |
Email using your custom domain | Depends on the email provider and plan |
For example, if you already own example.com, you may be able to connect it to a free hosting service without paying for another hosting subscription.
If you do not own a domain, you will generally need to register one. The price depends on the extension, registrar, promotional offers, and renewal rate.
The main idea is simple: you can often pay only for the domain while hosting your website for free.
2. Choose the Right Free Hosting Platform
Before deploying anything, decide where your website will be hosted. The best platform depends on the technology you are using.
Cloudflare Pages
Cloudflare Pages is a good option for static websites, documentation sites, blogs, and many frontend applications.
It supports Git-based deployments and custom domains. For static content, it can serve files through Cloudflare's network without requiring you to manage a traditional server.
Official documentation: https://developers.cloudflare.com/pages/
GitHub Pages
GitHub Pages is useful when your website consists of HTML, CSS, JavaScript, images, and other static assets.
It is especially convenient for developer portfolios, project documentation, and simple personal websites.
You can publish a website from a GitHub repository and connect a custom domain.
Official documentation: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site
Vercel
Vercel is particularly convenient for frontend developers working with Next.js and other supported frameworks.
You can import a Git repository, configure the project, and deploy it. Subsequent pushes to the connected repository can trigger new deployments automatically.
Custom domains are supported, but make sure the plan's usage rules fit your project. In particular, check whether a free plan permits your intended commercial use.
Official documentation: https://vercel.com/docs/domains/working-with-domains/add-a-domain
Netlify
Netlify is another option for static websites and frontend applications. It supports Git-based deployment, preview deployments, and custom domains.
It can be a good choice if you want to publish a site without managing a server.
Official documentation: https://docs.netlify.com/domains-https/custom-domains/
Which one should you choose?
For a simple HTML website, portfolio, or static blog, Cloudflare Pages or GitHub Pages is a good place to start.
For a Next.js project, Vercel may provide a particularly convenient deployment workflow. Cloudflare Pages can also support many frontend frameworks, depending on the project's build and runtime requirements.
Netlify is another solid choice for static and frontend projects.
Do not choose a platform just because it is popular. Check how it handles your framework, build process, custom domain, and expected traffic.
3. Step One: Prepare Your Website for Deployment
Let's start with a basic website. You do not need a complex application to follow this tutorial.
Suppose your project contains these files:
my-website/
├── index.html
├── style.css
├── script.js
└── images/
└── profile.webpThis is a static website because the browser can load the files without requiring a backend server to generate each page.
You can host this type of website on Cloudflare Pages or GitHub Pages.
If you are using React or Vite, the process is slightly different because you generally need to build the application before publishing it.
For example, a Vite project might have this structure:
my-website/
├── public/
├── src/
├── package.json
├── index.html
└── vite.config.jsFirst, install the dependencies:
npm installThen create a production build:
npm run buildFor a standard Vite application, the generated website files are usually placed in the dist directory.
my-website/
├── src/
├── public/
└── dist/
├── index.html
└── assets/The hosting platform needs to publish the generated files, not your development source files as though they were a finished website.
For a standard Vite project, the usual build configuration is:
Setting | Value |
|---|---|
Framework preset | Vite, if available |
Build command |
|
Output directory |
|
If you are using a different framework, the build command and output directory may differ.
Before moving forward, make sure your project builds successfully on your local machine. Fix any missing dependencies or build errors first. Otherwise, you may end up debugging the hosting configuration when the real problem is inside your application.
4. Step Two: Upload Your Website to GitHub
One of the easiest ways to deploy a website is to connect your GitHub repository to your hosting platform.
This also makes future updates much easier.
If you have not created a repository yet, open GitHub, sign in, and create a new repository.
Then open your project in the terminal.
If Git has not been initialized in your project, run:
git init
git add .
git commit -m "Initial website commit"Set your main branch and connect the repository:
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
git push -u origin mainReplace YOUR_USERNAME and YOUR_REPOSITORY with your actual GitHub username and repository name.
If your project is already connected to GitHub, you do not need to repeat these commands. Simply commit and push your latest changes.
One important thing: Never upload API keys, database passwords, private credentials, or other secrets to a public repository. Add the appropriate files to .gitignore and use your hosting provider's environment variable settings for server-side secrets.
Once your code is available on GitHub, you can connect the repository to a hosting service.
5. Step Three: Deploy Your Website on Cloudflare Pages
Let's use Cloudflare Pages as an example because it provides a straightforward workflow for static websites.
The exact dashboard labels can change, but the general process remains similar.
Create your project
Open the Cloudflare dashboard.
Navigate to Workers & Pages.
Choose the option to create an application or project.
Select the Pages deployment option.
Connect your GitHub account if prompted.
Select the repository containing your website.
Configure the build settings.
Start the deployment.
For a standard Vite project, configure the build command as:
npm run buildSet the build output directory to:
distFor a plain HTML website, you generally do not need a build command. Set the output directory to the folder containing your website's final files.
Follow the platform's current setup instructions if the dashboard presents different options.
Wait for the deployment to finish
Once the deployment succeeds, Cloudflare Pages will provide a default address for your project, typically ending in pages.dev.
Open that address and check whether your website loads correctly.
Test the important parts:
Does the homepage load?
Are the images visible?
Does the CSS work?
Do JavaScript interactions work?
Are internal links correct?
Does the website look good on mobile?
If everything works, your website is already live.
You have completed the hosting part without paying for a traditional web server.
Now comes the interesting part: connecting your own domain.
6. Step Four: Buy a Custom Domain or Use One You Already Own
A custom domain is the address people use to access your website.
For example:
Default hosting URL:
my-website.pages.dev
Custom domain:
mywebsite.com
Another example:
blog.mywebsite.comYou can register a domain through a domain registrar, or use a domain you already own.
Before purchasing a domain, consider the following:
Choose a name that is easy to remember.
Avoid unnecessary hyphens and complicated spelling.
Check whether the name is available.
Compare the first-year price with the renewal price.
Make sure you control the account used to register the domain.
A domain might be advertised at a low introductory price but renew at a higher rate. Check the renewal cost before purchasing it.
You do not need to buy hosting from the same company where you purchased your domain.
For example, you can register a domain through one provider and host the website on Cloudflare Pages, Vercel, Netlify, or GitHub Pages.
These are separate services.
Your domain registrar manages the domain registration, while the hosting provider serves your website. DNS connects the two.
7. Step Five: Connect Your Custom Domain to Cloudflare Pages
Suppose you have registered mywebsite.com and want your website to open at that address.
You need to configure the domain in Cloudflare Pages and make the appropriate DNS changes.
Add the domain to your project
Open your Cloudflare Pages project.
Navigate to the custom domain settings and select the option to add a domain.
Enter the domain you want to use:
mywebsite.comFollow the instructions shown in the dashboard.
The steps differ depending on whether you are connecting a root domain, such as mywebsite.com, or a subdomain, such as www.mywebsite.com.
What is the difference between a root domain and a subdomain?
A root domain, also called an apex domain, is the main domain without a prefix.
For example:
mywebsite.comA subdomain is a separate address created under the main domain.
Examples include:
www.mywebsite.com
blog.mywebsite.com
app.mywebsite.comYou can use a subdomain for a particular section of your website. For example, your main portfolio might use mywebsite.com, while your technical blog uses blog.mywebsite.com.
Configure the DNS records
DNS stands for Domain Name System. It helps browsers find the correct destination for a domain name.
Depending on your hosting provider and domain configuration, you may need to add records such as A or CNAME records.
For example, a CNAME record for a subdomain might look like this:
Field | Example value |
|---|---|
Type | CNAME |
Name |
|
Target | Your assigned Pages hostname |
TTL | Auto, if available |
The target must be the hostname specified by your hosting provider. Do not copy the example hostname above as though it were your actual deployment address.
For a root domain such as mywebsite.com, Cloudflare Pages requires the domain to be configured as a Cloudflare zone, with the relevant nameservers pointed to Cloudflare. Follow the current dashboard instructions to complete the setup.
If your domain uses another DNS provider, you may be able to connect a subdomain using a CNAME record without moving the entire domain's DNS management to Cloudflare. The available options depend on the hosting platform and domain configuration.
Important: Add the custom domain to your hosting project before manually creating DNS records. Follow the platform's recommended order so the domain is associated with the correct project.
8. Step Six: Understand DNS Propagation
After saving your DNS records, your domain might not start working immediately.
This is normal.
DNS changes take time to become visible across different DNS resolvers. This process is commonly called DNS propagation.
Depending on the change and DNS caching, the update may become visible quickly or take longer.
During this period, you might notice that:
Your website opens on one network but not another.
The old website appears temporarily.
The domain works without
wwwbut not with it.The browser reports that the site cannot be reached.
HTTPS is not ready yet.
Do not repeatedly change DNS records just because the website does not work immediately. First verify that the records match the values supplied by your hosting provider.
You can also inspect DNS records from your terminal.
For example, on macOS or Linux:
dig mywebsite.comTo inspect a subdomain's CNAME record:
dig www.mywebsite.com CNAMEReplace the example domain with your actual domain.
These commands help you inspect the DNS information visible to your current resolver. They do not guarantee that every DNS resolver worldwide has updated.
If the records are correct, give the changes time to take effect.
9. Step Seven: Enable HTTPS for Your Custom Domain
Your website may now open using your custom domain, but there is one more thing you should check: HTTPS.
Compare these two addresses:
http://mywebsite.com
https://mywebsite.comHTTPS encrypts the connection between the visitor's browser and your website. It helps protect information exchanged over the connection and is essential for modern websites.
The good news is that many modern hosting platforms provide HTTPS certificates automatically for supported custom domains.
With Cloudflare Pages, Vercel, Netlify, and GitHub Pages, you generally do not need to purchase a separate SSL certificate for a standard supported setup.
How do you check whether HTTPS is working?
Open your website using the HTTPS address:
https://mywebsite.comCheck that the page loads without a certificate warning.
Also, test the www version if you have configured it:
https://www.mywebsite.comYou should decide which address is your primary domain and configure the other version to redirect to it.
For example, you might choose https://mywebsite.com as the primary address and redirect www.mywebsite.com to it.
Alternatively, you can choose the www version as your primary address.
The important thing is to configure the redirects properly rather than leaving visitors with inconsistent versions of your website.
If HTTPS is not working immediately after you connect the domain, check the DNS records and the certificate status in your hosting dashboard. Certificate issuance can take time, and incorrect DNS records or restrictive CAA records can prevent successful issuance.
Do not disable security features simply to make the domain work. Fix the underlying configuration instead.
10. Can You Host a React or Next.js Website for Free?
Yes, but the answer depends on how your application works.
A simple React application can often be deployed as a static website after you build it.
For example, if you use Vite, run:
npm run buildThen deploy the generated dist directory to a compatible hosting platform.
For a Create React App project, the output directory is typically build, although the framework and project configuration determine the actual output.
Once the deployment is successful, you can connect your custom domain using the same general process described earlier.
What about Next.js?
Next.js needs a little more consideration.
Some Next.js applications can be exported as static files, while others rely on server-side rendering, API routes, server actions, or other server functionality.
If your application uses features that require a server runtime, simply uploading the static files will not reproduce the complete application.
For a Next.js project, Vercel is often a convenient starting point because it supports Next.js deployment workflows.
You can also consider other platforms that support the specific Next.js features your application uses.
Before deploying, check whether your project requires:
Server-side rendering.
API routes or route handlers.
Server actions.
Image optimization.
Middleware or other runtime features.
Environment variables.
Database connectivity.
Some of these features can be supported on free plans, but availability, usage limits, and restrictions vary by provider.
For example, a static portfolio built with Next.js may be easy to host for free, while a dynamic application with authentication, database operations, and frequent server-side requests may need additional services.
My suggestion: Start by identifying which parts of your application need a server. This will help you choose the right hosting platform and avoid deployment problems later.
11. What If Your Website Uses Node.js and MongoDB?
This is where things become slightly different.
Suppose you have built a MERN stack application with:
React or Next.js on the frontend.
Node.js and Express on the backend.
MongoDB as the database.
You cannot generally host the entire application by uploading the frontend files to a static hosting service.
Your frontend may be suitable for static hosting, but the Express API requires a compatible server runtime.
A typical deployment architecture could look like this:
Visitors
|
v
Custom Domain
|
v
React Frontend
Free Hosting
|
v
Node.js API
Compatible Hosting
|
v
MongoDB
Managed DatabaseEach component can be hosted separately.
For example, you might host the frontend on Cloudflare Pages and deploy the backend to a service that supports Node.js applications. Your MongoDB database can run on a compatible managed database service.
This setup can be inexpensive, and some providers offer free tiers for certain components. However, the availability and limitations of those free tiers can change.
Configure your API URL
Your frontend needs to know where your backend API is hosted.
For a Vite application, you could use an environment variable:
VITE_API_URL=https://api.mywebsite.comThen access it in your frontend code:
const API_URL = import.meta.env.VITE_API_URL;
async function getProducts() {
const response = await fetch(`${API_URL}/api/products`);
if (!response.ok) {
throw new Error("Failed to fetch products");
}
return response.json();
}Configure the environment variable in your hosting dashboard as well as in local development, where appropriate.
Remember that Vite variables prefixed with VITE_ are exposed to browser-side code. Never store database passwords, private API keys, or other server secrets in them.
If you want to use a subdomain such as api.mywebsite.com, configure that domain on your backend hosting platform and add the DNS records it provides.
You may also need to configure CORS on your Express server so that your frontend's origin is allowed to make API requests.
For example:
import cors from "cors";
app.use(
cors({
origin: "https://mywebsite.com",
})
);This is a basic example for a frontend hosted at one origin. If you also use a www domain, preview deployments, or other approved origins, configure them deliberately. If your application uses cookies for authentication, you will need to configure credentials, cookie attributes, and related security settings appropriately.
Hosting the frontend for free does not automatically make the backend or database free. Check the limits of each service before launching your application.
12. Common Problems When Connecting a Custom Domain
Most custom-domain problems come down to DNS configuration, an incomplete domain setup, or an issue with the deployed application.
Problem 1: The domain is not opening
First, check whether the deployment works using the default hosting URL.
If the default URL works but the custom domain does not, inspect the custom domain settings and DNS records.
Verify that the records point to the destination specified by your hosting provider.
Avoid guessing IP addresses or copying DNS records from unrelated tutorials.
Problem 2: The root domain works, but www does not
These are separate hostnames and may require separate DNS configuration.
For example:
mywebsite.com
www.mywebsite.comCheck whether both hostnames have been added to your hosting project and whether the required DNS records exist.
Then configure the preferred hostname and redirect the other one if your hosting platform supports it.
Problem 3: HTTPS is not working
Check the certificate status in your hosting dashboard.
Verify that the domain points to the correct hosting destination and that there are no conflicting DNS records.
If you have restrictive CAA records, confirm that they permit the certificate authority used by your hosting provider.
Allow time for the certificate to be issued before repeatedly changing your configuration.
Problem 4: The website opens, but images or CSS are missing
This is often an application build or asset-path issue rather than a domain problem.
Check your browser's developer tools and inspect the Network tab for failed requests.
For a Vite application, review the base configuration if the project is deployed under a subpath. For a normal custom-domain deployment at the root, the default configuration is often sufficient.
Also, verify that asset filenames and paths match the files produced by your build.
Problem 5: The website works, but the API requests fail
If the frontend loads but API requests fail, check the browser's Console and Network tabs.
Common causes include:
An incorrect API URL.
CORS configuration errors.
A backend service that is unavailable.
Invalid environment variables.
Authentication cookie settings.
An API endpoint that returns an error.
Test the API endpoint separately before changing the frontend or DNS configuration.
The key is to identify whether the problem belongs to DNS, HTTPS, frontend assets, or the backend API.
13. Is Free Hosting Good Enough for a Production Website?
Free hosting can be a perfectly reasonable choice for some production websites.
For example, a personal portfolio, technical blog, documentation website, or static landing page may not need a paid server at all.
However, the decision depends on the website's requirements.
Website type | Is free hosting a reasonable choice? |
|---|---|
Personal portfolio | Yes, often |
Static HTML/CSS website | Yes, often |
Technical blog built as a static site | Yes, often |
Project documentation | Yes, often |
Static business landing page | Potentially, subject to plan terms |
Dynamic MERN application | Depends on backend and database requirements |
Application with background workers | Depends on worker support and usage limits |
High-traffic e-commerce platform | Requires careful evaluation of reliability, resources, and plan terms |
For a small website, paying for a traditional server may not provide much value if the free hosting plan already meets your needs.
On the other hand, if your website handles customer accounts, payments, business operations, or sensitive information, you should carefully consider reliability, backups, monitoring, security, and recovery requirements.
You should also review the provider's acceptable-use policy and commercial-use restrictions. A free plan that is suitable for a personal portfolio may not be appropriate for a commercial application.
Do not upgrade just because someone says every serious website needs paid hosting. Upgrade when your requirements justify it.
14. A Few Things I Recommend Before Launching
Once your website is live, take a few minutes to check the details that are easy to overlook.
Test the website on mobile. A site that looks good on a desktop may have layout issues on smaller screens.
Check the HTTPS version. Make sure the certificate is valid and that your preferred domain works correctly.
Set up redirects. Decide whether the root domain or www version should be primary.
Add basic SEO information. Use a descriptive page title, a useful meta description, and appropriate canonical URLs where needed.
Optimize images. Large images can make a website feel slow even when the hosting platform is fast.
Check your links. Make sure navigation, contact links, and important pages work.
Keep your domain registration active. Free hosting cannot help if your domain expires.
Keep your code backed up. A Git repository gives you a useful history of changes and makes redeployment easier.
Review your hosting usage. Free plans have limits, and understanding them early can help you avoid unexpected interruptions.
Finally, test the website from another device or network. This is a simple way to catch issues that may not be obvious when you are testing locally.
Conclusion
Hosting a website for free with a custom domain is easier than it used to be. You no longer need to purchase a traditional hosting package just to publish a portfolio, blog, or static website.
Platforms such as Cloudflare Pages, GitHub Pages, Vercel, and Netlify offer free hosting options for supported projects, along with custom-domain support and HTTPS.
The basic process is straightforward: prepare your website, upload your code to GitHub, deploy it to a compatible platform, connect your domain, configure the DNS records, and verify HTTPS.
The main expense is usually the domain registration itself.
If you are a developer building a portfolio or technical blog, I would start with a free static hosting platform and spend time making the website fast, accessible, and useful. You can always move to a different platform when your requirements change.
For a full-stack application, evaluate the frontend, backend, and database separately. You may be able to host some components for free while paying for others that need more resources.
You do not need an expensive server to put your first website online. Start with what you need, understand the limitations, and upgrade only when there is a real reason to do so.
Technical author and software engineer at DevByte. Writing deep-dive tutorials on distributed systems, modern full-stack web architectures, and cloud deployments.


