Skip to content
🧮 Is Lifetime with ZapX Pass worth it? Work it out for your own servers in 30 seconds. Open the Lifetime calculator →

Set Up AdGuard Home on a Linux Server – Filter Ads and Trackers via DNS

Set up AdGuard Home as a One-Click App or with Docker Compose on your VPS, and filter ads and trackers using DNS-over-HTTPS without exposing an open DNS server to the internet.

2 December 202612 min read10 Views0 helpful

Introduction

AdGuard Home is a DNS server with built-in filtering for ads, trackers, and malicious sites. Devices that use AdGuard Home as their DNS server won't get an address back for domains on the blocklists. This lets you filter ads for all your devices at once without installing an ad blocker on each device. In the web interface, you can see which domains were requested and blocked, manage blocklists and allowlists, and create your own rules.

There is one thing to keep in mind when using a VPS: the server is directly connected to the internet. A DNS server that responds to everyone on port 53 is an open resolver and can be abused for DDoS attacks. For this reason, it's best for your devices to access AdGuard Home securely through DNS-over-HTTPS (DoH) using the app's address. Only allow classic DNS on port 53 for your own IP addresses. We'll show you two ways to set it up: the easy way, as a One-Click App, and a manual installation with Docker Compose.

When AdGuard Home Makes Sense on a VPS

AdGuard Home on a VPS is a good choice if:

  • You want to filter ads and trackers while you're away from home: With DNS-over-HTTPS, your browser, laptop, and smartphone use your filter on any network, including mobile networks.
  • You don't want to keep a device running at home all the time, such as a Raspberry Pi, and your server is already running around the clock.
  • You want your own DNS filter with logging: You can see which domains each device requests and block or allow individual domains.
  • You want encrypted DNS without using a third-party provider: Your requests go to your server and are then forwarded to an upstream DNS server of your choice.

A VPS is less suitable if you want to use AdGuard Home as a DHCP server on your home network or resolve devices on your home network by name. For that, AdGuard Home needs to be on the same local network. You can connect devices without DNS-over-HTTPS support, such as many smart TVs and game consoles, only through classic DNS on port 53, and only from approved IP addresses.

DNS-over-HTTPS or Classic DNS on Port 53?

The connection method you choose determines whether you need to open anything in the firewall:

DNS-over-HTTPS using the app's addressClassic DNS on port 53
Suitable forBrowsers, Windows 11, macOS, iOS, laptops, and smartphones while away from homeRouters or devices without DoH support
Firewall access requiredNoYour IP address in the adguard-dns IP set
Changing home IP addressNot a problemAdd the new IP address each time
EncryptedYesNo

For most users, DNS-over-HTTPS is the better option. Classic DNS on port 53 is mainly useful if you have a connection with a static IP address, such as at an office, and want to point the router there to your server.

The Easy Way: AdGuard Home as a One-Click App

You can install AdGuard Home in a few clicks using your VPS's One-Click Apps. The app creates the admin account with generated credentials, so no setup wizard appears. You can access the web interface and DNS-over-HTTPS over HTTPS using the app's address. On a VPS, the installation blocks classic DNS on port 53 in the Network firewall for all addresses you haven't explicitly allowed.

Requirements

  • A Linux VPS with One-Click Apps set up. See Set Up One-Click Apps for instructions.
  • AdGuard Home uses few resources: 1 CPU core, 256 MB of available memory, and 1 GB of storage are enough. If you plan to keep query logs and statistics for a longer period, allow for 512 MB and 5 GB.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search for AdGuard Home in the App catalog and click Install app.
  3. Leave Use a custom subdomain or zap.cloud enabled and choose an address. You need this address not only for the web interface but also for DNS-over-HTTPS.
  4. Under App configuration, the optional ADGUARD_DNS_BIND_ADDRESS field has a default value of 0.0.0.0. Leave this value as is. ZapX generates a username and password for the admin account during installation.
  5. Click Queue installation.

On a VPS, the installation creates the empty adguard-dns IP set and two rules in the Network firewall: the first allows DNS only from addresses in this IP set, and the second blocks DNS for all other addresses. Requests from the VPS itself are not affected.

Warning: Ubuntu: Port 53 Is Already in Use

On Ubuntu, the systemd-resolved system service uses port 53 on the server. The app card will then report that the app couldn't start because port 53 is already in use on the server. If this happens, open App environment using the gear icon on the app card, enter your VPS's public IP address for ADGUARD_DNS_BIND_ADDRESS, click Save, and restart the app using Restart on the app card. AdGuard Home will then run alongside systemd-resolved.

First Login

  1. Open App environment using the gear icon on the app card. Under Automatically generated values, you'll find the username (SERVICE_USER_ADGUARD) and password (SERVICE_PASSWORD_ADGUARD). Click the eye icon to show them, or the icon next to it to copy them. The note under Login on the app card lists the names of these two values.
  2. Open the app's Access link. AdGuard Home will take you straight to the login page.
  3. Sign in with the generated credentials.
  4. Under “Settings” > “DNS settings,” check the upstream DNS server. Quad9 over DNS-over-HTTPS is selected by default. You can also enter multiple upstream servers.

You can't change the password in the web interface because there is no option for it. See the FAQ for instructions on resetting it.

Info: Web Interface Port

AdGuard Home runs on port 3000 in the app, and the app's address points to this port. Don't change the web interface port, or AdGuard Home will no longer be accessible at its address.

Connect Devices Using DNS-over-HTTPS

DNS-over-HTTPS works without any firewall configuration. Your DoH address consists of the app's address, /dns-query, and a device name of your choice, called the ClientID:

Code
https://adguard.example.com/dns-query/laptop

Using a different ClientID for each device lets you see which device requested which domain in the query log. ClientIDs can contain only lowercase letters, numbers, and hyphens. Here's how to enter the address:

  • Firefox: “Settings” > “Privacy & Security” > “DNS over HTTPS” > “Max Protection,” provider “Custom.”
  • Chrome and Edge: “Settings” > “Privacy and security” > “Security” > “Use secure DNS,” provider “Custom.”
  • Windows 11: In network settings, set DNS server assignment to “Manual,” enter your VPS's IP address as the IPv4 DNS server, and under “DNS over HTTPS,” select “On (manual template)” and enter your DoH address.
  • iPhone, iPad, and Mac: Use a configuration profile with your DoH address. In AdGuard Home, go to “Setup Guide” > “DNS Privacy” for instructions for each system.

Allow Only Your Own Devices

To prevent anyone else from using your DNS-over-HTTPS filter, allow only your own ClientIDs:

  1. In AdGuard Home, open “Settings” > “DNS settings” and scroll down to “Access settings.”
  2. Under “Allowed clients,” enter your devices' ClientIDs, one per line, for example, laptop and phone. If you're also using classic DNS, enter the IP addresses you've allowed in the adguard-dns IP set as well.
  3. Click “Save.”

AdGuard Home will no longer respond to requests from other clients. Keep your DoH addresses secret, just like a password.

Allow Classic DNS on Port 53

If you want to connect a router or a device without DoH support, add your connection's public IP address to the adguard-dns IP set:

  1. Open your VPS and go to the Network firewall tab.
  2. Under IP Sets, expand the adguard-dns set using Details.
  3. Under Add entry, enter your public IP address, optionally add a comment, and click Entry.

After a few seconds, AdGuard Home will respond to DNS requests from that address. You can also ask Zappy, the AI assistant in the ZapX dashboard, to add your IP address. If your connection's IP address changes, add the new address and remove the old one using the trash icon.

Warning: Never Allow Port 53 for Everyone

Don't delete the DNS blocking rule or add an entire network, such as 0.0.0.0/0, to the IP set. Otherwise, AdGuard Home will respond to DNS requests from anywhere on the internet. Open resolvers like these are abused to attack others, which can have consequences for your server. The rules work only while Firewall active is turned on in the Network firewall tab. A firewall on the server itself, such as ufw, won't help here because Docker can expose published ports through it.

AdGuard Home on a Dedicated Server

A Dedicated Server doesn't have a Network Firewall in the ZapX dashboard. Initially, the One-Click App responds to DNS requests only on the server itself (127.0.0.1). If you want to use AdGuard Home on your network, enter the address where DNS should be available in ADGUARD_DNS_BIND_ADDRESS under App environment, then restart the app. The safest option is an address that only your own devices can access, such as one on a private network or VPN. If you open port 53 on a public IP address, allow access in your firewall only for your own devices. DNS-over-HTTPS using the app's address also works here without any firewall configuration.

Updates and Backup

  • Updates: Open the app card's gear menu, go to App update, and click Check for updates. If a new version is available, install it using Apply update. AdGuard Home updates the blocklists itself.
  • Backup: The settings are stored in the AdGuardHome.yaml file in the adguardhome-conf volume, and logs and statistics are stored in the adguardhome-work volume. Both are included in your VPS's Backups.
Info: Installations from Before 2026-12-02

Older installations were set up using the setup wizard. App update won't offer an update for these installations because the app setup has changed. Your app will continue to run as before, and your own admin account will remain valid. For these installations, the app card displays generated credentials that don't apply. ZapX creates the port 53 firewall rules only for new installations.

Manual Installation

If you want to run AdGuard Home without One-Click Apps, for example, on a server with your own reverse proxy, install it with Docker Compose. This guide is based on AdGuard Home's official Docker instructions.

Requirements

  • A Linux server running Debian or Ubuntu that you can access over SSH.
  • Docker with the Compose plugin. See Set Up Docker.
  • A domain pointing to your server's IP address, for example, adguard.example.com. Without a domain, you can't use HTTPS and therefore can't use DNS-over-HTTPS.
ResourceMinimumRecommended
CPU1 core1 core
Memory256 MB512 MB
Storage1 GB5 GB

Prepare the Firewall

For this setup, you only need SSH, as well as HTTP and HTTPS for the reverse proxy. Keep ports 53 and 3000 closed:

Code
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

For more information about ufw, see Manage the Firewall on Linux.

Install with Docker Compose

Create a directory and add the compose.yaml file to it:

Code
mkdir -p ~/adguard-home
cd ~/adguard-home
nano compose.yaml

Add the following content:

Code
services:
  adguardhome:
    image: adguard/adguardhome:v0.107.80
    restart: unless-stopped
    environment:
      - ADGUARD_HOME_DEFAULT_WEB_PORT=3000
    ports:
      - "127.0.0.1:53:53/tcp"
      - "127.0.0.1:53:53/udp"
      - "127.0.0.1:3000:3000/tcp"
    volumes:
      - ./work:/opt/adguardhome/work
      - ./conf:/opt/adguardhome/conf

The important lines:

  • image specifies a fixed version, so you can decide when to update.
  • ADGUARD_HOME_DEFAULT_WEB_PORT=3000 makes the setup wizard suggest port 3000 for the web interface.
  • 127.0.0.1: before the ports binds DNS and the web interface to the server itself only. You can access AdGuard Home externally only through the reverse proxy.
  • ./conf contains the settings, while ./work contains logs, statistics, and filter lists.

Start the container:

Code
docker compose up -d
Info: Ubuntu and Port 53

Ubuntu runs its own DNS service on 127.0.0.53 using systemd-resolved. Because the Compose file binds port 53 to 127.0.0.1 only, the two services don't conflict. However, if you bind port 53 to all addresses, the container won't start on Ubuntu and will display the address already in use message.

First Access

The setup wizard is accessible without logging in. Whoever opens it first creates the admin account. So open it through an SSH tunnel before setting up the reverse proxy. On your own computer:

Code
ssh -L 3000:127.0.0.1:3000 root@SERVER_IP

Then open http://localhost:3000 in your browser and follow the wizard:

  1. Leave port 3000 selected for “Admin Web Interface” and port 53 for “DNS server.”
  2. Set a username and a strong password for the admin account.
  3. Complete the wizard and sign in.

Access over HTTPS Using a Reverse Proxy

Set up nginx as a reverse proxy as described in Set Up a Reverse Proxy with nginx, and obtain a certificate; see Create an SSL Certificate. The server block for AdGuard Home:

Code
server {
    listen 443 ssl;
    server_name adguard.example.com;

    ssl_certificate     /etc/letsencrypt/live/adguard.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/adguard.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

To let AdGuard Home handle DNS-over-HTTPS behind the proxy, stop the container and open conf/AdGuardHome.yaml:

Code
docker compose stop
nano conf/AdGuardHome.yaml

In the http: section, under doh:, set insecure_enabled to true. Also, under dns:, add the line - 172.16.0.0/12 to trusted_proxies so AdGuard Home gets your devices' real IP addresses from the proxy. Then restart AdGuard Home with docker compose up -d. Your DoH address will be https://adguard.example.com/dns-query/<ClientID>. Connect your devices as described in the easy setup section.

Back Up Your Data

All data is in the ~/adguard-home directory. To create a backup, briefly stop the container and archive the directory:

Code
cd ~/adguard-home
docker compose stop
tar czf ~/adguard-home-backup-$(date +%F).tar.gz conf work
docker compose start

To back up only the settings, conf/AdGuardHome.yaml is enough.

Update AdGuard Home

Check the latest version on the releases page, enter it for image in compose.yaml, and restart:

Code
cd ~/adguard-home
docker compose pull
docker compose up -d

Always update AdGuard Home in the container using the image, not the web interface. Your settings in conf will remain unchanged.

Filters, Clients, and Logs

After setup, you'll mainly use three areas of the web interface:

  • “Filters” > “DNS blocklists”: The AdGuard DNS filter list is enabled by default. Use “Add blocklist” to choose more lists from the available options or enter a custom URL. More lists block more content, but they can also block things you need more often.
  • “Filters” > “Custom filtering rules”: Add your own rules, such as ||example.org^ to block a domain or @@||example.org^ to allow a domain that a list has blocked by mistake.
  • “Query Log”: See each request, including the device, domain, and result. Click a blocked request to allow that domain directly.

Under “Settings” > “Client settings,” create a named client for each ClientID. You can configure blocklists, parental controls, and Safe Search for each client, such as stricter rules for your children's tablet.

Limitations

  • Android “Private DNS” uses DNS-over-TLS on port 853. Neither setup in this guide configures this connection. On Android, use DoH in your browser, such as Chrome or Firefox.
  • DHCP and names on your home network work only if AdGuard Home is on the same local network.
  • Apps with built-in DNS, such as some smart TVs, bypass your filter.

Conclusion

With AdGuard Home, you filter ads and trackers via DNS for all your devices, even when you're on the go. Next, the guide Set Up WireGuard Easy on a Linux Server shows you how to set up your own VPN with a web interface so your devices stay securely connected on the go.

If you have any other questions or need help, our support team is available every day! 🙂

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the right choice for most users: the address, HTTPS, and admin account are set up for you, port 53 is blocked in the VPS Network Firewall for any addresses you haven't allowed, and you can install updates with one click. Manual installation with Docker Compose is a good fit if you want to integrate AdGuard Home into an existing setup with your own reverse proxy or configure every setting yourself.
A DNS server that responds to everyone is an open resolver. Attackers can send it small requests with a forged sender address, causing your server to send large responses to a victim. This makes your server part of a DDoS attack. That's why the One-Click App blocks port 53 in the VPS Network Firewall. Use DNS-over-HTTPS through the app's address, or add only your own IP addresses to the adguard-dns IP set.
Yes, using DNS-over-HTTPS. On iPhone and iPad, set up a configuration profile with your DoH address. On Android, enter the DoH address in your browser, such as Chrome or Firefox. Android's “Private DNS” feature uses DNS-over-TLS on port 853, which this guide doesn't configure.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.