Run Self-Hosted Services on a Raspberry Pi & Cut Costs
This guide shows you how to replace several paid cloud subscriptions with self-hosted services running on a Raspberry Pi. By the end, you’ll have your own private cloud storage, ad-blocking DNS, and media streaming—all for the cost of the hardware and electricity. This cuts recurring monthly fees and gives you full control over your data.
What You’ll Need
- A Raspberry Pi (3, 4, or 5 recommended; Pi Zero 2 W works for lighter services)
- A microSD card (16GB or larger, Class 10 or A2 for speed)
- A power supply (official adapter recommended, 5V/3A for Pi 4/5)
- An Ethernet cable or stable Wi-Fi connection
- A computer to prepare the SD card
- Optional: external USB drive for media storage
Step-by-Step
- Install the operating system. Download Raspberry Pi Imager from the official website and install it on your computer. Insert the SD card, open Imager, choose “Raspberry Pi OS Lite (64-bit)� (no desktop needed), select your SD card, and click Write. For headless setup, before writing, click the gear icon to enable SSH and set a username and password.
- Boot and connect. Insert the SD card into the Pi, connect power, and wait a minute. Find the Pi’s IP address from your router’s admin page or use a network scanner. Then SSH from your computer:
ssh pi@<IP_ADDRESS>(use your chosen username). - Update the system. Run
sudo apt update && sudo apt upgrade -yto get the latest packages and security fixes. - Set a static IP. To keep services reachable, assign a fixed local IP. Edit
/etc/dhcpcd.conf(or use your router’s DHCP reservation) and add lines like:interface eth0,static ip_address=192.168.1.50/24,static routers=192.168.1.1,static domain_name_servers=1.1.1.1. Reboot withsudo reboot. - Install Docker. Docker makes installing and managing services easy. Run the convenience script:
curl -fsSL https://get.docker.com | sh. Then add your user to the docker group:sudo usermod -aG docker $USER. Log out and back in. - Install Portainer (optional but helpful). Portainer gives a web UI for Docker. Run:
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest. Access it athttps://<PI_IP>:9443. - Set up Pi-hole for ad-blocking. Pi-hole blocks ads at the network level, replacing a premium ad-blocker. Run:
docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN --restart=always -e TZ="Your/Timezone" -v pihole_etc:/etc/pihole -v pihole_dnsmasq:/etc/dnsmasq.d pihole/pihole:latest. Then set your router’s DNS to the Pi’s IP (or configure DHCP to hand it out). You’ll get a web dashboard athttp://<PI_IP>/admin. - Set up Jellyfin for media streaming. Jellyfin is a free, open-source media server that can replace Netflix for your own movies and music. Create a folder for media:
mkdir ~/media. Then run:docker run -d --name jellyfin -p 8096:8096 --restart=always -v ~/media:/media -v jellyfin_config:/config jellyfin/jellyfin:latest. Access the web UI athttp://<PI_IP>:8096and follow the setup wizard. - Set up Nextcloud for file storage. Nextcloud replaces Dropbox/Google Drive. Run:
docker run -d --name nextcloud -p 8080:80 --restart=always -v nextcloud_data:/var/www/html nextcloud:latest. Access it athttp://<PI_IP>:8080and create an admin account. - Secure remote access (optional). To access services from outside your home, use a VPN like WireGuard or Tailscale. Tailscale is easiest: install with
curl -fsSL https://tailscale.com/install.sh | sh, then runsudo tailscale up. This gives you a private network that works anywhere, avoiding exposing ports to the internet. - Automate backups. Back up your SD card and data regularly. Use
rsyncto copy important folders to an external drive, or create a cron job. For Docker volumes, usedocker run --rm -v nextcloud_data:/data -v /backup:/backup alpine tar czf /backup/nextcloud.tar.gz -C /data .
Common Mistakes
- Using a cheap power supply. This causes random crashes and SD card corruption. Use the official adapter or a quality 5V/3A one.
- Not setting a static IP. If the IP changes, you lose access to all services until you find the new one.
- Forgetting to update. Regular updates are essential for security and stability.
- Exposing ports to the internet. Opening port 80 or 443 without a VPN is risky. Use a VPN or reverse proxy with proper security.
- Ignoring SD card wear. Logs and frequent writes can wear out the card. Use a high-endurance card or move logs to RAM.
Tips
- Use a UPS or power bank to protect against power cuts.
- Monitor temperature: keep the Pi below 80°C. Add a heatsink or fan if needed.
- Use an external USB drive for media and large files to reduce SD card wear.
- Group services in Docker Compose for easier management. Create a
docker-compose.ymlfile with all services defined. - Set up log rotation to avoid filling the SD card.
Troubleshooting
- Can’t SSH: Ensure SSH is enabled (create an empty file named
sshin the boot partition). Check the Pi is on the network and you’re using the correct IP and username. - Docker won’t install: Make sure the Pi is connected to the internet and you’re using a supported OS (Raspberry Pi OS 64-bit).
- Pi-hole not blocking ads: Verify your router’s DNS is set to the Pi’s IP. Test with
nslookup doubleclick.net <PI_IP>– it should return 0.0.0.0. - Jellyfin can’t find media: Check the folder permissions. The container runs as a specific user; set
PUIDandPGIDenvironment variables to match your user. - Nextcloud is slow: Use Redis for caching and enable PHP OPcache. Add
--link redis:redisand run a Redis container. - Pi keeps crashing: Check power supply and temperature. Run
vcgencmd measure_tempanddmesg | tailfor errors.
Frequently Asked Questions
How much does it cost to run a Raspberry Pi 24/7?
Electricity cost is roughly $5–$10 per year, depending on your electricity rate. The Pi draws about 5W at idle.
Can I use a Raspberry Pi Zero 2 W for this?
Yes, for Pi-hole and light file sharing, but it lacks the power for Jellyfin transcoding or heavy Nextcloud use.
Is it safe to expose my Pi to the internet?
Not directly. Use a VPN (like Tailscale) or a reverse proxy with SSL and strong authentication. Avoid opening ports without protection.
What if I don’t have a router that allows custom DNS?
You can manually set DNS on each device, or use Pi-hole as a DHCP server (disable DHCP on your router).
Can I migrate my existing data from Google Drive to Nextcloud?
Yes, use the Nextcloud desktop client or a tool like rclone to sync files from Google Drive to your Nextcloud.
How do I update all my Docker containers?
Use docker-compose pull and docker-compose up -d if using Compose, or manually pull and recreate each container.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.