PGO
← News

PGO / ARTICLE

How to Host a Website From Your Computer (Step by Step)

How to host a website from your computer: set up a local server, go public with a tunnel or port forwarding, add a domain and SSL, and know the risks.

Navy and gold graphic reading Host a Website From Your Own Computer, with the subtitle local server, tunnel or port forwarding

Yes, you can host a website from your own computer. You install web server software, put your site’s files in its folder, and then open it to the internet, either by forwarding a port on your router or by running a tunnel that connects your computer to the web without opening any ports. It is a brilliant way to learn, test and show work to a client. It is a poor way to run a business site that must stay online every hour of the day, and I will show you exactly why further down.

I have written before on how to host a website the normal way, with a hosting company. This guide is the do-it-yourself version, where your laptop or desktop becomes the server.

What hosting a website from your computer actually means

A web host is just a computer that stays connected to the internet and answers when a browser asks for a page. Any computer can do that job if it runs the right software. The difference between your laptop and a server in a data centre is not magic. It is stable power, a fast and steady connection, a fixed public address, cooling, backups and people watching it around the clock.

So when you host from home, you take on all of those jobs yourself. Keep that in mind as you go through the steps.

What you need before you start

  • A computer that can stay on. Windows, macOS or Linux all work. An old laptop you no longer use is perfect for this.
  • Web server software. Apache and Nginx are the two most common. For beginners, a bundle like XAMPP installs Apache, a database (MariaDB) and PHP in one go.
  • Your website files, or a WordPress download if you want to run WordPress.
  • A steady internet connection with decent upload speed, because visitors download your pages from your upload side.
  • Optional: a domain name. You can test without one, but a real site needs an address people can remember. Here is my guide on how to choose a domain name.

Step 1: Run the website on your own machine first

Start locally. Nobody else can see the site yet, which makes this the safe place to get things working.

The quickest test for a simple HTML site

If your site is plain HTML, CSS and JavaScript, and you have Python installed, open a terminal in the folder that holds your index.html and run:

python3 -m http.server 8000

Now open http://localhost:8000 in your browser and your site loads. This little server is fine for testing, but it is not meant for real public traffic, so do not leave it facing the internet.

The proper setup with XAMPP

Install XAMPP, open its control panel and start Apache (and MySQL if you need a database). Copy your site into the htdocs folder inside the XAMPP install folder, then visit http://localhost. If you want WordPress, create a database through phpMyAdmin, drop the WordPress files into a folder inside htdocs and run the installer in your browser.

localhost (also 127.0.0.1) simply means “this computer”. At this stage only you can see the site.

Step 2: Let other devices on your network see it

Find your computer’s local IP address (it usually looks like 192.168.x.x). On Windows, run ipconfig in Command Prompt. On a Mac, check the network settings for your Wi-Fi. Then, from a phone on the same Wi-Fi, type that address into the browser.

If the page does not load, your computer’s firewall is probably blocking it. Allow Apache (or whatever server you use) through the firewall for private networks and try again. This is a good point to show a client a design on your own network before anything goes public.

Step 3: Put the site on the public internet

This is where most people get stuck. You have two main options.

Option A: Use a tunnel (the easiest route)

A tunnel runs a small program on your computer that makes an outgoing connection to a provider’s network. Visitors reach the provider, and the provider passes their requests through the tunnel to your machine. You do not open any port on your router, and it works even when your internet provider does not give you a public IP address.

Cloudflare Tunnel is a popular free option. After installing the cloudflared program, one command gives your local site a temporary public address on trycloudflare.com:

cloudflared tunnel –url http://localhost:8000

Cloudflare describes these quick tunnels as intended for testing and development only. They get a random address, have a cap on concurrent requests and come with no uptime guarantee. For a site with your own domain, you create a named tunnel from a Cloudflare account and connect it to a domain that uses Cloudflare for its DNS. Visitors then get HTTPS at Cloudflare’s edge, so you do not have to set up a certificate on your computer for them. You can read the details in Cloudflare’s tunnel documentation.

Option B: Port forwarding (the traditional route)

Here you log in to your router and forward ports 80 (HTTP) and 443 (HTTPS) to your computer’s local IP address. Give the computer a fixed local IP (a DHCP reservation in the router) so the rule does not break when it reconnects.

Port forwarding has three common problems:

  • No public IP. Many providers, mobile networks especially, place customers behind carrier-grade NAT (CGNAT). Your router does not have its own public address, so forwarded ports never receive outside traffic. If the WAN address on your router is different from what a “what is my IP” site shows, this is likely your case, and a tunnel is the answer.
  • Your public IP changes. Most home connections get a dynamic IP. A dynamic DNS service keeps a hostname pointed at your current address as it changes.
  • Your provider may not allow it. Some internet providers block incoming traffic on port 80 or forbid running servers on home plans. Read your plan’s terms before you build anything on it.

If port forwarding works for you, get a free SSL certificate from Let’s Encrypt (the Certbot tool makes this simple) so your site loads with the padlock. Without it, browsers show visitors a warning. I explained that warning in my post on fixing the “Not secure” warning.

Step 4: Connect your domain name

With a tunnel, you add the domain to the tunnel’s settings and the DNS record is created for you. With port forwarding, you create an A record at your DNS provider that points the domain to your public IP, or a CNAME to your dynamic DNS hostname. If DNS records are new to you, read what DNS is and how it works first. Changes can take some time to spread, so give it a while before you decide something is broken.

Step 5: Lock it down

The moment your computer answers requests from the internet, strangers’ bots will start knocking. That is normal, so be ready.

  • Keep the operating system, the web server, PHP and WordPress updated.
  • Use strong passwords everywhere, and never expose phpMyAdmin or your database to the public.
  • Only forward the ports the website needs. Never forward remote desktop or file sharing ports.
  • If you can, use a separate old computer for this rather than the laptop that holds your banking and personal files.
  • Take backups of the site files and database, and store a copy somewhere other than that same computer.

The honest downsides of hosting at home

If your computer goes off, your website goes off. A power cut, a sleeping laptop, a Windows update restart or an internet outage takes the site down with it. Where power supply is not steady, that alone rules home hosting out for anything serious.

Speed is the next issue. Home connections usually have much slower upload than download, and every visitor pulls pages from your upload. A handful of visitors is fine. A post that goes viral is not.

Then there is your time. Security updates, backups and fixing things at midnight become your job.

When home hosting makes sense, and when it does not

Home hosting is a great fit for:

  • Learning how servers, DNS and SSL really work.
  • Testing a site or a WordPress theme before it goes live.
  • Showing a client a project for a few days.
  • Personal tools and hobby projects that can afford to be offline sometimes.

It is the wrong choice for a business website, an online store, a blog you want to monetise with AdSense, or anything that must stay reachable. Google cannot index pages it cannot reach, and visitors who find a dead site rarely come back.

For those sites, a hosting company does all the hard parts for you. At Trispark Hosting we run shared hosting with free SSL, daily backups and 24/7 support, so your site stays up when your laptop is closed. If you are not sure what kind of plan you need, my guides on shared hosting and free vs paid hosting will help you decide.

Common questions

Is it free to host a website from my computer?

The software can be free (Apache, Nginx, XAMPP, Let’s Encrypt and Cloudflare’s free tunnel all cost nothing to start). You still pay for electricity, internet data and, if you want a proper address, a domain name.

Can I host a WordPress site on my own computer?

Yes. Install XAMPP or a similar stack, create a database and run the WordPress installer from your htdocs folder. Most people do this to build and test, then move the finished site to a real host. My guide on moving a website to a new host covers that move.

Do I need a static IP address?

No. A tunnel does not need one at all, and with port forwarding a dynamic DNS service handles a changing IP. You do need a public IP for port forwarding, which some providers do not give.

Is hosting a website from home safe?

It can be reasonably safe if you keep everything updated, open only the ports you need and use a spare machine. A tunnel is safer than opening ports because nothing on your router is exposed.

Will Google index a site hosted on my computer?

Google can crawl and index it like any other site, as long as it is reachable when Googlebot visits. If your computer is often off, crawls fail and that hurts you.


More from PGO. Ready for a site that never sleeps? See Trispark Hosting, read how to choose web hosting for a blog, or learn the full skill set with Trispark Academy.

Share

Share this article.