Adjusting Pi-hole v6 Session Timeout and DNS Query Limits.
This is the Fourteenth in a series of posts, featuring Protips, tips, tricks, hacks, and secrets provided by Our Team 🙊 — We want to share our top tips for the growing and thriving Linux community out there. Because sometimes you need a little help...
Pi-hole v6 provides configuration options for controlling how long users remain logged in to the web interface and how the DNS resolver handles incoming requests.
By default, the web interface session timeout is 1,800 seconds (30 minutes). If you frequently access the dashboard, increasing this value can reduce unnecessary logins.
However, web sessions and DNS query limits are different settings. Understanding that distinction is essential when configuring Pi-hole v6. Pi-hole Documentation
1. Increase the Web Interface Session Timeout
Pi-hole v6 stores its main configuration in:
/etc/pihole/pihole.tomlThe default session timeout is configured under [webserver.session]:
[webserver.session]
timeout = 1800The timeout is expressed in seconds and determines how long an inactive session remains valid.
For example:
| Timeout | Duration |
|---|---|
1800 | 30 minutes |
3600 | 1 hour |
86400 | 24 hours |
604800 | 7 days |
2592000 | 30 days |
The web interface refreshes active sessions, so the timeout does not necessarily log you out while you are actively using the dashboard.
Change the timeout
You can update the setting directly through Pi-hole FTL's configuration interface.
To increase the timeout to one hour, run:
$ sudo pihole-FTL --config webserver.session.timeout 3600This configures the session timeout to 3,600 seconds.
Alternatively, edit the configuration file:
$ sudo nano /etc/pihole/pihole.tomlLocate the [webserver.session] section and change the value to:
[webserver.session]
timeout = 3600Save the file after making the change.
Note: Use one configuration method at a time. If you edit the TOML file directly, follow Pi-hole's configuration and restart requirements for your installation. The pihole-FTL --config method is preferable for straightforward changes because it uses Pi-hole's configuration interface.
Verify the setting
Read the configured value with:
$ sudo pihole-FTL --config webserver.session.timeoutThe command should report the configured timeout.
You can also manage session settings through the Pi-hole web interface under Settings → All settings → Web interface and API, although the exact layout may vary by release.
Security considerations
Longer sessions improve convenience but increase the time an unattended, authenticated browser session may remain valid.
For a personal home network, a longer timeout may be reasonable. On shared computers or systems administered by multiple people, shorter timeouts are generally safer.
2. Understanding MAXSESSIONS and DNS Query Limits
One important distinction: MAXSESSIONS is not the Pi-hole v6 setting for controlling the web interface session timeout or the DNS resolver's concurrent query limit.
Pi-hole v6 consolidates much of its configuration in /etc/pihole/pihole.toml, replacing several legacy configuration approaches.
There are two separate concepts to understand.
A. Web API sessions
Pi-hole v6 has a setting named webserver.api.max_sessions that controls the number of concurrent API sessions.
Its documented default is 16. This is a limit on API sessions, not simultaneous DNS queries.
B. Concurrent DNS queries
The DNS resolver has a separate setting, dns-forward-max, which controls the maximum number of concurrent forwarded DNS queries.
If you encounter a warning such as:
Maximum number of concurrent DNS queries reachedyou may need to review this DNS setting rather than changing the web session timeout.
Pi-hole v6 allows additional dnsmasq directives to be configured through misc.dnsmasq_lines. For example, to configure dns-forward-max to 300, you can use:
$ sudo pihole-FTL --config misc.dnsmasq_lines 'dns-forward-max=300'Important: This example configures the directive through Pi-hole's custom dnsmasq configuration mechanism. Check your existing misc.dnsmasq_lines settings before changing them, and ensure that any existing directives are preserved.
Increasing the limit is not automatically beneficial. Investigate the warning, DNS workload, and system resources before changing the value.
3. Apply and Troubleshoot Configuration Changes
If you change a setting and do not observe the expected behavior, verify the configured value first.
For the web session timeout:
$ sudo pihole-FTL --config webserver.session.timeoutFor the DNS configuration:
$ sudo pihole-FTL --config misc.dnsmasq_linesIf you edited pihole.toml manually, validate that the TOML structure and setting names are correct.
You can also generate a Pi-hole debug log to assist with troubleshooting:
$ sudo pihole -dIf you need to restart FTL after a manual configuration change, use:
$ sudo systemctl restart pihole-FTLBe aware that restarting FTL briefly interrupts DNS resolution for clients using that Pi-hole instance. Avoid unnecessary restarts, especially on networks that depend on Pi-hole for DNS.
Pi-hole v6 provides flexible configuration options for managing web sessions and DNS behavior.
- Web session timeout: Adjust
webserver.session.timeoutto control how long inactive sessions remain valid. - API session limit: Use
webserver.api.max_sessionsto configure the number of concurrent API sessions. - DNS query limit: Investigate
dns-forward-maxwhen addressing warnings about concurrent forwarded DNS queries.
These settings serve different purposes. Configure the one that matches your actual requirement, and avoid increasing limits without a clear operational reason.
Happy tweaking.