Independent, hands-on guides to hosting, SEO and marketing tools. No paid rankings, ever.See how we test →

How to Host a Website on a Raspberry Pi

Learn how to run a small website from a Raspberry Pi using Apache, DNS, HTTPS and sensible security checks.

Serp & Server is reader-supported. When you buy through links on our site, we may earn an affiliate commission, at no extra cost to you. It never decides our rankings. Here’s how it works.

How to host a website on a raspberry pi
Jump to a section

If you want to host a website on a raspberry pi, the good news is that the basic setup is well within reach for a careful beginner. A Raspberry Pi can run a small website from your home or office using the same kind of web server software found on bigger Linux servers.

This guide shows the practical route: install Raspberry Pi OS, set up Apache, add your files, connect a domain and keep the box safe. It also explains when raspberry pi website hosting is a fun project, and when normal hosting is the better business choice.

Should you host a website on a raspberry pi?

You can host a website on a raspberry pi if the site is small, the traffic is modest and you are happy to do a little maintenance. It is best for personal sites, test projects, local club pages, dashboards and learning how web hosting works.

Do not host a website on a raspberry pi if the site earns your income, handles sensitive customer data or must stay online all the time. A home internet connection, power cut or router change can take the site down without warning.

Think of it as a tiny server computer. If that idea is new, our plain-English guide to what a server computer is will make the rest of this tutorial easier.

What a Raspberry Pi is good at

  • Serving static HTML, CSS and images.
  • Running a light WordPress test site, not a busy shop.
  • Hosting an internal page for your home, office or workshop.
  • Helping you learn Linux, DNS, HTTPS and backups.

What you need before you start

To host a website on a raspberry pi, you need the board, storage, power, an internet connection and a domain name if you want public visitors. A wired Ethernet connection is strongly recommended because it is steadier than Wi-Fi.

Use Raspberry Pi OS Lite unless you need a desktop. The official Raspberry Pi documentation describes Lite as the command-line-only version, and Raspberry Pi Imager is the official tool for writing the OS to storage: Raspberry Pi OS documentation.

ItemRecommendationWhy it matters
Raspberry PiPi 4 or Pi 5Enough performance for a small site and web server packages.
StorageQuality microSD card or SSDCheap cards fail more often, especially with logs and updates.
PowerOfficial or reliable USB-C power supplyLow power causes crashes and file corruption.
NetworkEthernet to your routerReduces dropouts and makes IP addressing easier.
DomainAny domain with DNS controlLets visitors use a normal web address.

If you only want to publish a simple HTML site, compare this with easier free options in our guide to hosting an HTML website for free. A Pi is more hands-on, but you learn far more.

Set up the raspberry pi web server

The simplest way to host a website on a raspberry pi is to install Apache. Apache is a web server, which means it listens for browser requests and sends back web pages.

Network setup to host a website on a raspberry pi
A Raspberry Pi site needs a server, DNS and a safe route online.

The official Raspberry Pi remote access documentation includes Apache as a supported way to serve web pages from a Raspberry Pi, including the standard apache2 package: Raspberry Pi remote access documentation.

First, install Raspberry Pi OS Lite with Raspberry Pi Imager. In the Imager settings, set a hostname, username, password, Wi-Fi only if needed, locale and SSH access, then boot the Pi and connect with SSH from your main computer.

ssh youruser@raspberrypi.local
sudo apt update
sudo apt full-upgrade -y
sudo reboot

After the reboot, install Apache and check that it is running.

sudo apt install apache2 -y
sudo systemctl status apache2

On another device on the same network, open the Pi’s local IP address in a browser. If you see the default Apache page, your raspberry pi web server is working locally.

Find the Pi’s local IP address

If the hostname does not work, run this on the Pi:

hostname -I

Your router’s admin page may also show the Pi under connected devices. Reserve that address in the router settings so it does not change later.

Add your website files

Once Apache works, you can host a website on a raspberry pi by replacing the default web page. Apache normally serves files from /var/www/html on Debian-based systems such as Raspberry Pi OS.

Create a simple test page first. This avoids wondering whether a later problem is caused by your DNS, router or website files.

echo '<h1>Hello from my Raspberry Pi</h1>' | sudo tee /var/www/html/index.html

Refresh the local IP address in your browser. If the page changes, Apache is serving your own content.

Upload files properly

For a basic static site, copy your HTML, CSS, JavaScript and image files into /var/www/html. You can use scp, an SFTP app such as FileZilla, or Git if your site is in a repository.

scp -r ./my-site/* youruser@raspberrypi.local:/tmp/my-site/
ssh youruser@raspberrypi.local
sudo rsync -av /tmp/my-site/ /var/www/html/

If you plan to use WordPress, remember that you will also need PHP, a database, backups and more updates. For a business website, our types of web hosting guide explains when shared, VPS or cloud hosting is more sensible.

Make the site reachable from the internet

When you host a website on a raspberry pi at home, local access is only half the job. Public access needs a path from the internet to your Pi, plus DNS records that point your domain in the right place.

There are two common routes: port forwarding on your router, or a tunnel service. Port forwarding is direct, but it exposes your home IP address and depends on your internet provider allowing inbound traffic.

Option 1: port forwarding

With port forwarding, your router sends traffic on ports 80 and 443 to the Pi’s local IP address. Port 80 is used for normal HTTP and port 443 is used for HTTPS.

  1. Reserve the Pi’s local IP address in your router.
  2. Forward external port 80 to the Pi’s port 80.
  3. Forward external port 443 to the Pi’s port 443.
  4. Create an A record at your DNS provider pointing your domain to your public IP address.
  5. If your home IP changes, use dynamic DNS or update the record manually.

This may not work if your provider uses CGNAT, which means your router does not receive a unique public IPv4 address. In that case, a tunnel is usually easier.

Option 2: Cloudflare Tunnel

For many people, the easier way to host a website on a raspberry pi is to use a tunnel. Cloudflare Tunnel runs a small service on the Pi and makes an outbound connection, so you usually do not need router port forwarding.

Cloudflare’s documentation says Cloudflare Tunnel uses the cloudflared daemon to connect your infrastructure to Cloudflare: Cloudflare Tunnel setup documentation. This is often the tidier option for home networks, but you must be comfortable putting your DNS through Cloudflare.

Whichever route you choose, test from mobile data as well as from your home Wi-Fi. Some routers behave differently when you try to visit your own public address from inside the network.

Add HTTPS, updates and backups

If you host a website on a raspberry pi for public visitors, HTTPS is not optional. HTTPS encrypts the connection between the browser and your site, and modern browsers mark plain HTTP as less trustworthy.

Let’s Encrypt provides free domain-validated TLS certificates, and Certbot is the common tool for installing and renewing them on Apache. The Certbot documentation covers Apache on Debian-based systems: Certbot documentation.

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache

Certbot normally adds a renewal timer automatically, but you should still test it.

sudo certbot renew --dry-run

Basic maintenance checklist

  • Run system updates at least monthly.
  • Keep a copy of your site files somewhere other than the Pi.
  • Use strong passwords and SSH keys where possible.
  • Disable any services you do not need.
  • Check Apache logs if the site slows down or receives suspicious traffic.
  • Keep the Pi on a surge-protected power supply if uptime matters.

A raspberry pi website hosting setup is only as reliable as the home network around it. Your router, power, storage and ISP all become part of the hosting stack.

Troubleshooting common problems

If you cannot host a website on a raspberry pi successfully on the first attempt, work through the chain in order. Start with the Pi, then Apache, then your router, then DNS.

ProblemLikely causeWhat to try
Default page works locally, but not onlinePort forwarding or tunnel issueCheck router rules, firewall settings and whether your ISP blocks inbound traffic.
Domain does not loadDNS record wrong or not updated yetCheck the A record, CNAME or tunnel hostname in your DNS provider.
HTTPS failsCertificate validation cannot reach the PiMake sure the domain points to the server before running Certbot.
Site is slowLarge images, weak connection or heavy softwareCompress images, avoid heavy plugins and test from another network.
Site disappears after rebootApache not enabled or storage issueRun sudo systemctl enable apache2 and check system logs.

For static sites, ask whether you need the Pi online at all. Free static hosts can be faster and simpler, as covered in our GitHub Pages, Netlify and Cloudflare comparison.

If you are using the Pi to learn, the troubleshooting is part of the value. If you are using it for customers, downtime is a business risk.

How to Host a Website on a Raspberry Pi FAQs

Can I host a website on a raspberry pi for free?

Yes, you can host a website on a raspberry pi without paying for hosting, if you already own the hardware and have home internet. You may still need to pay for a domain name, and you are responsible for electricity, updates, backups and fixing downtime.

Is a raspberry pi web server fast enough for WordPress?

A raspberry pi web server can run WordPress for testing, learning or a very small personal site. It is not a good fit for a busy business site because WordPress also needs PHP, a database, caching and regular maintenance.

Do I need a static IP address for raspberry pi website hosting?

A static public IP address is helpful, but not always required. If your IP changes, you can use dynamic DNS or a tunnel service, although both add another moving part to your setup.

Is it safe to host a website on a raspberry pi at home?

It can be reasonably safe for a small project if you keep the system updated, use HTTPS, avoid unnecessary services and understand your router settings. It is riskier than managed hosting because your home network becomes part of the public setup.

What is the easiest website type to run on a Raspberry Pi?

A static website is the easiest because it uses simple files rather than a database-driven app. That makes it lighter, faster and less likely to break than a full content management system.

Final word

You can host a website on a raspberry pi, and it is one of the best small projects for understanding what web hosting really does. You will learn about Linux, Apache, domains, DNS, HTTPS and backups in a practical way.

For a hobby project, lab site or low-traffic personal page, raspberry pi website hosting can be rewarding. For a serious business website, start with our web hosting guides and choose a service built for uptime, support and security.

Enjoyed this guide?

Get the newsletter

Get more guides like this one on the topics you choose. Confirm your email and you are done.

  • Pick only the topics you care about
  • About one email a week, no spam
  • Change topics or unsubscribe any time
Newsletter signup


Serp & Server Avatar

Written by

Keep reading