If you’re running aaPanel with Nginx on your VPS and want to install Pi-hole to block ads and trackers at the DNS level, there’s one key detail you must watch out for: port conflicts with Nginx. Both Pi-hole’s web interface and Nginx default to using port 80, so installing them together without adjustment can cause errors or make one of the services unreachable. In this guide, you’ll learn how to install Pi-hole and set it up alongside Nginx without problems.
📌 What Is Pi-hole?
Pi-hole is a DNS-level ad and tracker blocker that protects every device on your local network. Once installed, it intercepts DNS queries and blocks domains associated with ads, trackers, and other unwanted content — improving privacy, browsing speed, and network performance.
⚠️ The Problem: Port Conflicts with Nginx
By default:
- Nginx (via aaPanel) listens on port 80 (HTTP) and 443 (HTTPS)
- Pi-hole’s web interface (Lighttpd) also tries to use port 80
Because two services cannot bind to the same port at the same time, this creates a conflict if not handled properly.
Before continuing, it’s useful to check which ports are in use:
sudo netstat -tuln | grep LISTENThis will show active ports and help you identify conflicts.
🔧 Best Fixes to Avoid the Conflict
Here are three practical ways to make Pi-hole and Nginx run together on the same server:

🟢 Option 1 — Change Pi-hole’s Lighttpd Port
One of the simplest fixes is to run Pi-hole’s admin interface on a different port than Nginx:
- Edit Pi-hole Lighttpd config:
sudo nano /etc/lighttpd/lighttpd.conf - Find the line:
server.port = 80 - Replace it with a free port, for example:
server.port = 8081 - Restart Lighttpd:
sudo systemctl restart lighttpd
Now you can access Pi-hole at:
http://your-server-ip:8081/adminThis avoids any Nginx conflict.
✔ Pros: Simple and quick
✖ Cons: You must include the port number in the URL
🟡 Option 2 — Change Nginx’s Port
If you want Pi-hole to stay on port 80, you can instead move Nginx:
- Edit the Nginx config in aaPanel:
/www/server/nginx/conf/nginx.conf - Change listening port:
listen 80;tolisten 8080; - Restart Nginx:
service nginx restart
Now Nginx runs on port 8080 while Pi-hole uses port 80.
✔ Pros: Pi-hole’s interface stays on default
✖ Cons: All other Nginx sites must use a custom port
🔵 Option 3 — Use Nginx as a Reverse Proxy (Recommended)
For a clean, professional setup, configure Nginx to act as a reverse proxy to Pi-hole while keeping HTTPS support through aaPanel:
Here’s a sample Nginx server block:
server {
listen 80;
server_name pihole.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}With this configuration:
✔ Nginx stays on standard ports (80/443)
✔ Pi-hole runs internally on a different port
✔ You can secure Pi-hole with SSL via Nginx and Let’s Encrypt
This approach is ideal if you plan to expose Pi-hole with a custom domain or secure access.
📊 Comparing the Methods
| Method | Easy to Set Up | Default Ports | SSL Support | Best For |
|---|---|---|---|---|
| Change Lighttpd Port | ⭐⭐⭐ | No | Basic | Small setups |
| Change Nginx Port | ⭐⭐ | Yes (Pi-hole) | Limited | Dedicated Pi-hole |
| Reverse Proxy | ⭐⭐⭐⭐ | Yes | Yes | Professional production |
📝 Quick Setup Checklist
✔ Install Pi-hole
✔ Run netstat -tuln to check ports
✔ Choose one of the three conflict solutions
✔ Adjust firewall rules (ports 80, 443, custom)
✔ Test access to Pi-hole’s dashboard

❓ FAQ – Pi-hole with aaPanel + Nginx
Do I need to uninstall Nginx to install Pi-hole?
No — you just need to avoid having both services try to use port 80 at the same time.
Can I use both Pi-hole and Nginx together?
Yes — just ensure they run on different ports, or configure Nginx as a reverse proxy.
Will Pi-hole affect server performance?
Pi-hole is lightweight and runs well even on low-resource VPS servers.
Can Pi-hole use HTTPS?
Yes — but Pi-hole itself uses HTTP internally. For HTTPS, set up SSL through Nginx and proxy traffic.
🏁 Conclusion
Installing Pi-hole alongside aaPanel and Nginx is entirely possible with just a bit of configuration. The most common issue — port conflict on port 80 — can be solved by changing one service’s port or using Nginx as a reverse proxy. The reverse proxy solution offers the cleanest and most secure setup, especially if you’re using domains and SSL certificates.
By following this guide, you’ll have a fully functioning Pi-hole DNS blocker running smoothly on your VPS without disrupting your Nginx-hosted sites and services.
Want to improve your security and protect your accounts?
Read more Security & Privacy articles →



