Hosting guide

How to Install Pi-hole on a VPS

By Gander Web · Updated 11 October 2026 · 3 min read

In short

Pi-hole blocks ads and trackers for every device on your network, before they load. Here is how to install it on an Ubuntu VPS, from the first SSH login to a working admin console.

What you need

A VPS running Ubuntu 22.04 or later, and SSH access to it. If you want to reach the admin console by a domain name, point that domain at the VPS first.

Connect and update

Log in over SSH, then bring the system packages up to date:

ssh root@your-vps-ip
sudo apt update
sudo apt upgrade

Install Pi-hole

Run the official installer:

curl -sSL https://install.pi-hole.net | bash

It asks a few questions, including which upstream DNS provider to use. Note the admin password it shows at the end, or set your own with sudo pihole setpassword.

Lock it down to your own IP

A Pi-hole on a public VPS will answer DNS for anyone who finds it unless you restrict it, and open resolvers get abused in DDoS amplification attacks. Allow DNS and the admin console only from your home or office IP address:

sudo ufw allow OpenSSH
sudo ufw allow from YOUR.HOME.IP to any port 53
sudo ufw allow from YOUR.HOME.IP to any port 80,443 proto tcp
sudo ufw enable

Pi-hole only answers local requests by default. Because your home network isn't local to the VPS, open Settings > DNS in the admin console and set the interface option to Permit all origins. That's safe only with the firewall rules above in place. If your home IP changes, reach the Pi-hole over a VPN such as WireGuard instead. See how to secure a Linux VPS for the rest of the basics.

Point your router at it

To block ads for every device at home, open your router's settings and set its DNS server to your VPS's IP address. To test first, change the DNS setting on one laptop or phone instead.

Open the admin console

Visit http://your-vps-ip/admin and log in with the admin password. The dashboard and query log show each blocked request, so browse for a minute and check it's working.

Add blocklists

To block more, open Lists under Group Management (called Adlists in older versions), add the list URL, then update Pi-hole's blocklist database:

pihole -g

Keep it updated

Update Pi-hole with pihole -up and the system with sudo apt upgrade once a month or so.

Need somewhere to run it?

Our UK VPS plans give you root access, a fixed IP and DDoS protection from £5.99 a month.

See VPS plans

Questions

What is Pi-hole?

Pi-hole is free, open-source software that acts as a network-wide DNS ad blocker. It blocks ads and trackers for every device on your network before they even load.

What do I need to run Pi-hole?

You need a Linux device that stays on: a Raspberry Pi, an old PC, or a Linux VPS, plus the ability to set it as your network's DNS server, usually in your router settings.

Can I run Pi-hole on a VPS?

Yes. Running Pi-hole on a Linux VPS gives you a Pi-hole you can reach from anywhere, which is ideal if you want network-wide blocking on the move or across multiple locations.

Does Pi-hole slow down my internet?

No. By blocking ad and tracker requests, pages often load faster and use less bandwidth. DNS lookups it does allow are cached, so browsing typically feels quicker.

Is Pi-hole free?

Yes, Pi-hole is completely free and open-source. Your only cost is the hardware or VPS you run it on.