pihole: Manage Pi-hole DNS


pihole: Manage Pi-hole DNS

Overview

The pihole command-line tool lets you control your Pi-hole DNS server from the terminal. It covers status checks, starting/stopping the daemon, updating Pi-hole and gravity, and manipulating the ad-blocking lists.

Quick start (essential tasks)

Start with a few core commands to see what Pi-hole is doing and keep it up to date.

pihole status
pihole enable
pihole disable
pihole reloaddns
pihole -up
pihole -g

Note: Some commands show up with alternative spellings in docs, like updatePihole or updateGravity. The common, supported forms are shown above.

Manage the daemon

  • Start or stop the Pi-hole service:
pihole enable
pihole disable
  • Check status to verify whether the daemon is running:
pihole status

Update and maintenance

  • Update Pi-hole itself (and optionally gravity):
pihole -up
  • Update the ad-blocking lists and DNS cache without restarting the DNS server:
pihole reloaddns
  • Update the gravity list (the ad-blocking domains):
pihole -g

Lists and domain management

  • Add domains to allowlist or denylist:
pihole allowlist example.com
pihole denylist badexample.org
  • Search for a domain in the lists:
pihole -q example.com

Real-time logs

  • Open a real-time log of connections:
pihole -t

Common pitfalls

  • Run as a user with sufficient privileges (often root). If commands fail “permission denied”, try prefixing with sudo or running as root.
  • Some features require the Pi-hole service to be running; use pihole status to confirm.
  • When updating gravity, ensure the device has network access; a failed update may leave DNS behavior inconsistent.
  • The web interface and the command-line tool share the same gravity lists—keep both in sync to avoid surprises.

Quick troubleshooting

  • If pihole status shows “not running”:
pihole enable
  • If updates hang or fail:
pihole -up
  • Check DNS resolution issues after reloaddns:
pihole -t

If issues persist, consult the official Pi-hole docs: https://docs.pi-hole.net/main/pihole-command

See Also