Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New v6 Install Does Not Read Domains from Block Lists #1747

Open
1 task done
mattforscale opened this issue Feb 23, 2025 · 12 comments
Open
1 task done

New v6 Install Does Not Read Domains from Block Lists #1747

mattforscale opened this issue Feb 23, 2025 · 12 comments

Comments

@mattforscale
Copy link

mattforscale commented Feb 23, 2025

This is a: Run Issue

When running a fresh install of pihole/pihole:2025.02.4, Gravity does not pull in any domains from my blocklist either via the web UI or command line. I have no issues adding individual domains to the blocklist

Image

Image

Same result when running via command line:

pi@pihole:~/pihole $ docker exec pihole sudo pihole -g
  Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp.
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...

  [✓] Preparing new gravity database
  [✓] Creating new gravity databases
  [✓] Pulling blocklist source list into range
  [i] Using libz compression

  [✗] Unable to write to /etc/pihole/listsCache
      Please run pihole -g as root

  [✓] Building tree
  [i] Number of gravity domains: 0 (0 unique domains)
  [i] Number of exact denied domains: 1
  [i] Number of regex denied filters: 0
  [i] Number of exact allowed domains: 0
  [i] Number of regex allowed filters: 0
  [✓] Optimizing database
  [✓] Swapping databases
  [✓] The old database remains available
  [✓] Cleaning up stray matter

  [✓] Done.

Any help is greatly appreciated!

Related Issues

  • I have searched this repository/Pi-hole forums for existing issues and pull requests that look similar

How to reproduce the issue

  1. Environment data
  • Operating System: Raspbian 10 - Buster
  • Hardware: Raspberry Pi 2 Model B
  • Kernel Architecture: ArmV7
  • Docker Install Info and version:
    • Software source: image tag pihole:2025.02.4
  • Hardware architecture: ARMv7
  1. docker-compose.yml contents, docker run shell command, or paste a screenshot of any UI based configuration of containers here
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:2025.02.4
    network_mode: host
#    ports:
      # DNS Ports
#      - "53:53/tcp"
#      - "53:53/udp"
      # Default HTTP Port
#      - "80:80/tcp"
      # Default HTTPs Port. FTL will generate a self-signed certificate
#      - "443:443/tcp"
      # Uncomment the below if using Pi-hole as your DHCP Server
      #- "67:67/udp"
    environment:
      # Set the appropriate timezone for your location from
      # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones, e.g:
      TZ: 'America/New York'
      # Set a password to access the web interface. Not setting one will result in a random password being assigned
      FTLCONF_webserver_api_password: 'REDACTED'
      # If using Docker's default `bridge` network setting the dns listening mode should be set to 'all'3
      FTLCONF_dns_listeningMode: 'all'
    # Volumes store your data between container upgrades
    volumes:
      # For persisting Pi-hole's databases and common configuration file
      - '/home/pi/pihole/etc-pihole:/etc/pihole'
      # For persisting custom dnsmasq config files. Most will not need this, and can be safely removed/commented out
#      - '/home/pi/pihole/etc-dnsmasq.d:/etc/dnsmasq.d'
    cap_add:
      # Required if you are using Pi-hole as your DHCP server, else not needed
      # See Note On Capabilities below
      - NET_ADMIN
    restart: unless-stopped
  1. any additional info to help reproduce

While the updater implies possible permission issues, I have no other issues when writing to these directories. I've successfully written a test file to the listsCache directory from inside the container. As noted above, there are no issues when adding individual domains to the block list.

Here are the volume permissions (inside and outside) the container

pi@pihole:~/pihole/etc-pihole $ ll
total 1784
-rw-rw---- 1 pi   pi        65 Feb 23 08:08 adlists.list
-rw-r----- 1 pi   pi        44 Feb 23 08:08 cli_pw
drwxr-xr-x 2 pi   pi      4096 Feb 23 07:47 config_backups
-rw-rw---- 1 pi   pi      1192 Feb 23 08:10 dhcp.leases
-rw-rw---- 1 pi   pi      5421 Feb 22 14:54 dnsmasq.conf
drwxr-xr-x 2 pi   pi      4096 Feb 23 08:08 gravity_backups
-rw-rw-r-- 1 pi   pi    102400 Feb 23 08:08 gravity.db
-rw-r----- 1 root root  102400 Feb 23 08:08 gravity_old.db
drwxr-xr-x 2 pi   pi      4096 Feb 22 14:48 hosts
drwxr-xr-x 2 pi   pi      4096 Feb 22 14:46 listsCache
-rw-r--r-- 1 root root     421 Feb 23 08:08 logrotate
drwxr-xr-x 2 pi   pi      4096 Feb 22 18:47 migration_backup
-rw-r----- 1 pi   pi   1302528 Feb 23 08:08 pihole-FTL.db
-rw-r----- 1 pi   pi     32768 Feb 23 08:11 pihole-FTL.db-shm
-rw-r----- 1 pi   pi    164832 Feb 23 08:11 pihole-FTL.db-wal
-rw-rw---- 1 pi   pi     52491 Feb 23 07:47 pihole.toml
-rw-rw---- 1 pi   pi       733 Feb 22 14:48 tls_ca.crt
-rw-rw---- 1 pi   pi       713 Feb 22 14:48 tls.crt
-rw-rw---- 1 pi   pi      1001 Feb 22 14:48 tls.pem
-rw-r--r-- 1 pi   pi       380 Feb 23 08:08 versions
pi@pihole:~/pihole/etc-pihole $
pi@pihole:~/pihole/etc-pihole $
pi@pihole:~/pihole/etc-pihole $ docker exec pihole ls -l /etc/pihole
total 1784
-rw-rw---- 1 pihole pihole      65 Feb 23 13:08 adlists.list
-rw-r----- 1 pihole pihole      44 Feb 23 13:08 cli_pw
drwxr-xr-x 2 pihole pihole    4096 Feb 23 12:47 config_backups
-rw-rw---- 1 pihole pihole    1192 Feb 23 13:10 dhcp.leases
-rw-rw---- 1 pihole pihole    5421 Feb 22 19:54 dnsmasq.conf
-rw-rw-r-- 1 pihole pihole  102400 Feb 23 13:08 gravity.db
drwxr-xr-x 2 pihole pihole    4096 Feb 23 13:08 gravity_backups
-rw-r----- 1 root   root    102400 Feb 23 13:08 gravity_old.db
drwxr-xr-x 2 pihole pihole    4096 Feb 22 19:48 hosts
drwxr-xr-x 2 pihole pihole    4096 Feb 22 19:46 listsCache
-rw-r--r-- 1 root   root       421 Feb 23 13:08 logrotate
drwxr-xr-x 2 pihole pihole    4096 Feb 22 23:47 migration_backup
-rw-r----- 1 pihole pihole 1302528 Feb 23 13:08 pihole-FTL.db
-rw-r----- 1 pihole pihole   32768 Feb 23 13:11 pihole-FTL.db-shm
-rw-r----- 1 pihole pihole  164832 Feb 23 13:11 pihole-FTL.db-wal
-rw-rw---- 1 pihole pihole   52491 Feb 23 12:47 pihole.toml
-rw-rw---- 1 pihole pihole     713 Feb 22 19:48 tls.crt
-rw-rw---- 1 pihole pihole    1001 Feb 22 19:48 tls.pem
-rw-rw---- 1 pihole pihole     733 Feb 22 19:48 tls_ca.crt
-rw-r--r-- 1 pihole pihole     380 Feb 23 13:08 versions

Here is the log that is produced when I run the updater via the web UI:

2025-02-23 13:16:00.925 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/pihole-FTL.db-wal
2025-02-23 13:16:02.926 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity_old.db
2025-02-23 13:16:02.926 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db
2025-02-23 13:16:02.926 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/pihole-FTL.db-wal
2025-02-23 13:16:02.926 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp
2025-02-23 13:16:02.927 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.926 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.927 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.927 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:03.927 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.927 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-mj0AB03B953
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-mj0AB03B953
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-mj0AB03B953
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:03.928 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.929 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:03.930 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:04.927 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:04.928 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:04.928 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:04.928 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db_temp-journal
2025-02-23 13:16:04.929 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db_temp
2025-02-23 13:16:04.929 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity_old.db
2025-02-23 13:16:04.929 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity_old.db
2025-02-23 13:16:04.929 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.930 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.930 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.930 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.930 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.930 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.931 UTC [56/T90] DEBUG_INOTIFY: File created: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.931 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.931 UTC [56/T90] DEBUG_INOTIFY: File deleted: /etc/pihole/gravity.db-journal
2025-02-23 13:16:04.931 UTC [56/T90] DEBUG_INOTIFY: File written: /etc/pihole/gravity.db
2025-02-23 13:16:04.932 UTC [56/T90] DEBUG_INOTIFY: File moved from: /etc/pihole/gravity.db
2025-02-23 13:16:04.932 UTC [56/T90] DEBUG_INOTIFY: File moved from: /etc/pihole/gravity.db_temp
2025-02-23 13:16:04.932 UTC [56/T90] DEBUG_INOTIFY: File moved to: /etc/pihole/gravity.db
2025-02-23 13:16:04.976 UTC [56M] DEBUG_ANY: dnsmasq received signal 17
2025-02-23 13:16:05.031 UTC [56/T89] INFO: Gravity database has been updated, reloading now
2025-02-23 13:16:05.034 UTC [56/T89] DEBUG_ANY: Closing gravity database
2025-02-23 13:16:05.051 UTC [56/T89] INFO: Compiled 0 allow and 0 deny regex for 17 clients in 1.5 msec

I have tried other blocklists as well

These common fixes didn't work for my issue

  • [ X] I have tried removing/destroying my container, and re-creating a new container
  • [ X] I have tried fresh volume data by backing up and moving/removing the old volume data
  • [X ] I have tried running the stock docker run example(s) in the readme (removing any customizations I added)
  • [ X] I have tried a newer or older version of Docker Pi-hole (depending what version the issue started in for me)
  • [ X] I have tried running without my volume data mounts to eliminate volumes as the cause
@yubiuser
Copy link
Member

Could you please run the more verbose output from within the container

bash -x /opt/pihole/gravity.sh

@mattforscale
Copy link
Author

Yes. And thanks for the quick response!

pi@pihole:~/pihole/etc-pihole $ docker exec pihole bash -x /opt/pihole/gravity.sh
+ export LC_ALL=C
+ LC_ALL=C
+ PI_HOLE_SCRIPT_DIR=/opt/pihole
+ utilsfile=/opt/pihole/utils.sh
+ . /opt/pihole/utils.sh
+ coltable=/opt/pihole/COL_TABLE
+ . /opt/pihole/COL_TABLE
++ '[' -t 1 ']'
++ '[' '' ']'
++ COL_BOLD=
++ COL_ULINE=
++ COL_NC=
++ COL_GRAY=
++ COL_RED=
++ COL_GREEN=
++ COL_YELLOW=
++ COL_BLUE=
++ COL_PURPLE=
++ COL_CYAN=
++ COL_WHITE=
++ COL_BLACK=
++ COL_LIGHT_BLUE=
++ COL_LIGHT_GREEN=
++ COL_LIGHT_CYAN=
++ COL_LIGHT_RED=
++ COL_URG_RED=
++ COL_LIGHT_PURPLE=
++ COL_BROWN=
++ COL_LIGHT_GRAY=
++ COL_DARK_GRAY=
++ TICK='[✓]'
++ CROSS='[✗]'
++ INFO='[i]'
++ QST='[?]'
++ DONE=' done!'
++ OVER='\r'
+ . /etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh
++ readonly scriptPath=/etc/.pihole/advanced/Scripts/database_migration/gravity
++ scriptPath=/etc/.pihole/advanced/Scripts/database_migration/gravity
+ basename=pihole
+ PIHOLE_COMMAND=/usr/local/bin/pihole
+ piholeDir=/etc/pihole
+ listsCacheDir=/etc/pihole/listsCache
+ whitelistFile=/etc/pihole/whitelist.txt
+ blacklistFile=/etc/pihole/blacklist.txt
+ regexFile=/etc/pihole/regex.list
+ adListFile=/etc/pihole/adlists.list
+ piholeGitDir=/etc/.pihole
++ getFTLConfigValue files.gravity
++ pihole-FTL --config -q files.gravity
+ GRAVITYDB=/etc/pihole/gravity.db
++ getFTLConfigValue files.gravity_tmp
++ pihole-FTL --config -q files.gravity_tmp
+ GRAVITY_TMPDIR=/tmp
+ gravityDBschema=/etc/.pihole/advanced/Templates/gravity.db.sql
+ gravityDBcopy=/etc/.pihole/advanced/Templates/gravity_copy.sql
+ domainsExtension=domains
+ curl_connect_timeout=10
+ etag_support=false
+ '[' '!' -d /tmp ']'
+ '[' '!' -w /tmp ']'
+ echo -e '  Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp. '
+ GRAVITY_TMPDIR=/tmp
  Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp.
+ gravityDBfile=/etc/pihole/gravity.db
+ gravityDBfile_default=/etc/pihole/gravity.db
+ gravityTEMPfile=/etc/pihole/gravity.db_temp
++ dirname -- /etc/pihole/gravity.db
+ gravityDIR=/etc/pihole
+ gravityOLDfile=/etc/pihole/gravity_old.db
+ gravityBCKdir=/etc/pihole/gravity_backups
+ gravityBCKfile=/etc/pihole/gravity_backups/gravity.db
+ [[ -f /etc/pihole/gravity_old.db ]]
+ rm /etc/pihole/gravity_old.db
+ gravity_Trap
+ trap '{ echo -e "\\n\\n  ${INFO} ${COL_LIGHT_RED}User-abort detected${COL_NC}"; gravity_Cleanup "error"; }' INT
+ [[ '' == true ]]
+ [[ '' == true ]]
+ migrate_to_listsCache_dir
+ [[ -d /etc/pihole/listsCache ]]
+ return
+ timeit migrate_to_database
+ local start_time end_time elapsed_time ret
++ date +%s%3N
+ start_time=1740318124447
+ migrate_to_database
+ '[' '!' -e /etc/pihole/gravity.db ']'
+ upgrade_gravityDB /etc/pihole/gravity.db /etc/pihole
+ local database piholeDir version
+ database=/etc/pihole/gravity.db
+ piholeDir=/etc/pihole
+ [[ ! -f /etc/pihole/gravity.db ]]
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db 'SELECT "value" FROM "info" WHERE "property" = '\''version'\'';'
+ version=19
+ [[ 19 == \1 ]]
+ [[ 19 == \2 ]]
+ [[ 19 == \3 ]]
+ [[ 19 == \4 ]]
+ [[ 19 == \5 ]]
+ [[ 19 == \6 ]]
+ [[ 19 == \7 ]]
+ [[ 19 == \8 ]]
+ [[ 19 == \9 ]]
+ [[ 19 == \1\0 ]]
+ [[ 19 == \1\1 ]]
+ [[ 19 == \1\2 ]]
+ [[ 19 == \1\3 ]]
+ [[ 19 == \1\4 ]]
+ [[ 19 == \1\5 ]]
+ [[ 19 == \1\6 ]]
+ [[ 19 == \1\7 ]]
+ [[ 19 == \1\8 ]]
+ ret=0
+ [[ '' != true ]]
+ return 0
+ [[ '' == true ]]
+ timeit gravity_CheckDNSResolutionAvailable
+ local start_time end_time elapsed_time ret
++ date +%s%3N
+ start_time=1740318124505
+ gravity_CheckDNSResolutionAvailable
+ local lookupDomain=raw.githubusercontent.com
+ timeout 4 getent hosts raw.githubusercontent.com
+ echo -e '\r  [✓] DNS resolution is available\n'
+ return 0
  [✓] DNS resolution is available

+ ret=0
+ [[ '' != true ]]
+ return 0
+ gravity_DownloadBlocklists
+ echo -e '  [i] Neutrino emissions detected...'
  [i] Neutrino emissions detected...
+ [[ /etc/pihole/gravity.db != \/\e\t\c\/\p\i\h\o\l\e\/\g\r\a\v\i\t\y\.\d\b ]]
+ local url domain str target compression adlist_type directory success

+ echo ''
+ str='Preparing new gravity database'
+ echo -ne '  [i] Preparing new gravity database...'
  [i] Preparing new gravity database...+ rm /etc/pihole/gravity.db_temp
+ output='++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp'
+ status=0
+ [[ 0 -ne 0 ]]
  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
+ str='Creating new gravity databases'
+ echo -ne '  [i] Creating new gravity databases...'
++ cat /etc/.pihole/advanced/Templates/gravity_copy.sql
+ copyGravity='.timeout 30000

ATTACH DATABASE '\''/etc/pihole/gravity.db'\'' AS OLD;

BEGIN TRANSACTION;

DROP TRIGGER tr_domainlist_add;
DROP TRIGGER tr_client_add;
DROP TRIGGER tr_adlist_add;

INSERT OR REPLACE INTO "group" SELECT * FROM OLD."group";

INSERT OR REPLACE INTO domainlist SELECT * FROM OLD.domainlist;
DELETE FROM OLD.domainlist_by_group WHERE domainlist_id NOT IN (SELECT id FROM OLD.domainlist);
INSERT OR REPLACE INTO domainlist_by_group SELECT * FROM OLD.domainlist_by_group;

INSERT OR REPLACE INTO adlist SELECT * FROM OLD.adlist;
DELETE FROM OLD.adlist_by_group WHERE adlist_id NOT IN (SELECT id FROM OLD.adlist);
INSERT OR REPLACE INTO adlist_by_group SELECT * FROM OLD.adlist_by_group;

INSERT OR REPLACE INTO client SELECT * FROM OLD.client;
DELETE FROM OLD.client_by_group WHERE client_id NOT IN (SELECT id FROM OLD.client);
INSERT OR REPLACE INTO client_by_group SELECT * FROM OLD.client_by_group;


CREATE TRIGGER tr_domainlist_add AFTER INSERT ON domainlist
    BEGIN
      INSERT INTO domainlist_by_group (domainlist_id, group_id) VALUES (NEW.id, 0);
    END;

CREATE TRIGGER tr_client_add AFTER INSERT ON client
    BEGIN
      INSERT INTO client_by_group (client_id, group_id) VALUES (NEW.id, 0);
    END;

CREATE TRIGGER tr_adlist_add AFTER INSERT ON adlist
    BEGIN
      INSERT INTO adlist_by_group (adlist_id, group_id) VALUES (NEW.id, 0);
    END;


COMMIT;'
+ [[ /etc/pihole/gravity.db != \/\e\t\c\/\p\i\h\o\l\e\/\g\r\a\v\i\t\y\.\d\b ]]
+ output='++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp'
+ status=0
+ [[ 0 -ne 0 ]]
+ echo -e '\r  [✓] Creating new gravity databases'
+ mapfile -t sources
  [✓] Creating new gravity databases
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db 'SELECT address FROM vw_adlist;'
+ mapfile -t sourceIDs
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db 'SELECT id FROM vw_adlist;'
+ mapfile -t sourceTypes
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db 'SELECT type FROM vw_adlist;'
+ mapfile -t sourceDomains
++ awk -F '[/:]' '{
      # Remove URL protocol & optional username:password@
      gsub(/(.*:\/\/|.*:.*@)/, "", $0)
      if(length($1)>0){print $1}
      else {print "local"}
    }'
+++ printf '%s\n' https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
  [✓] Pulling blocklist source list into range
+ local 'str=Pulling blocklist source list into range'
+ echo -e '\r  [✓] Pulling blocklist source list into range'
+ [[ -z https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts ]]
+ [[ -z raw.githubusercontent.com ]]
+ curl -V
+ grep -q 'Features:.* libz'
+ compression=--compressed
+ echo -e '  [i] Using libz compression\n'
  [i] Using libz compression

+ curl --help all
+ grep -q etag-save
+ etag_support=true
+ (( i = 0 ))
+ (( i < 1 ))
+ url=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
+ domain=raw.githubusercontent.com
+ id=1
+ [[ 0 -eq 0 ]]
+ str=blocklist
+ adlist_type=gravity
+ saveLocation=/etc/pihole/listsCache/list.1.raw.githubusercontent.com.domains
+ activeDomains[i]=/etc/pihole/listsCache/list.1.raw.githubusercontent.com.domains
++ dirname -- /etc/pihole/listsCache/list.1.raw.githubusercontent.com.domains
+ directory=/etc/pihole/listsCache
+ '[' '!' -w /etc/pihole/listsCache ']'
+ echo -e '  [✗] Unable to write to /etc/pihole/listsCache'
+ echo '      Please run pihole -g as root'
+ echo ''
+ continue
+   [✗] Unable to write to /etc/pihole/listsCache
      Please run pihole -g as root

(( i++ ))
+ (( i < 1 ))
+ gravity_Blackbody=true
+ update_gravity_timestamp
+ output='++ printf '\''.timeout 30000\nINSERT OR REPLACE INTO info (property,value) values ('\''\'\'''\''updated'\''\'\'''\'',cast(strftime('\''\'\'''\''%%s'\''\'\'''\'', '\''\'\'''\''now'\''\'\'''\'') as int));'\''
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp'
+ status=0
+ [[ 0 -ne 0 ]]
+ return 0
+ fix_owner_permissions /etc/pihole/gravity.db_temp
+ chown pihole:pihole /etc/pihole/gravity.db_temp
+ chmod 664 /etc/pihole/gravity.db_temp
++ dirname -- /etc/pihole/gravity.db_temp
+ chmod g+w /etc/pihole
+ timeit gravity_build_tree
+ local start_time end_time elapsed_time ret
++ date +%s%3N
+ start_time=1740318125859
+ gravity_build_tree
+ local str
+ str='Building tree'
+ echo -ne '  [i] Building tree...'
  [i] Building tree...+ output='++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp '\''CREATE INDEX idx_gravity ON gravity (domain, adlist_id);'\'''
+ status=0
+ [[ 0 -ne 0 ]]
+ echo -e '\r  [✓] Building tree'
+ ret=0
+ [[ '' != true ]]
+ return 0
+ timeit gravity_ShowCount
+ local start_time end_time elapsed_time ret
  [✓] Building tree
++ date +%s%3N
+ start_time=1740318125939
+ gravity_ShowCount
+ gravity_Table_Count gravity 'gravity domains'
+ local table=gravity
+ local 'str=gravity domains'
+ local num
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM gravity;'
+ num=0
+ [[ gravity == \g\r\a\v\i\t\y ]]
+ local unique
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM (SELECT DISTINCT domain FROM gravity);'
+ unique=0
+ echo -e '  [i] Number of gravity domains: 0 (0 unique domains)'
+ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'INSERT OR REPLACE INTO info (property,value) VALUES ('\''gravity_count'\'',0);'
  [i] Number of gravity domains: 0 (0 unique domains)
+ gravity_Table_Count 'domainlist WHERE type = 1 AND enabled = 1' 'exact denied domains'
+ local 'table=domainlist WHERE type = 1 AND enabled = 1'
+ local 'str=exact denied domains'
+ local num
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM domainlist WHERE type = 1 AND enabled = 1;'
  [i] Number of exact denied domains: 1
+ num=1
+ [[ domainlist WHERE type = 1 AND enabled = 1 == \g\r\a\v\i\t\y ]]
+ echo -e '  [i] Number of exact denied domains: 1'
+ gravity_Table_Count 'domainlist WHERE type = 3 AND enabled = 1' 'regex denied filters'
+ local 'table=domainlist WHERE type = 3 AND enabled = 1'
+ local 'str=regex denied filters'
+ local num
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM domainlist WHERE type = 3 AND enabled = 1;'
+ num=0
+ [[ domainlist WHERE type = 3 AND enabled = 1 == \g\r\a\v\i\t\y ]]
+ echo -e '  [i] Number of regex denied filters: 0'
+ gravity_Table_Count 'domainlist WHERE type = 0 AND enabled = 1' 'exact allowed domains'
+ local 'table=domainlist WHERE type = 0 AND enabled = 1'
+ local 'str=exact allowed domains'
+ local num
  [i] Number of regex denied filters: 0
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM domainlist WHERE type = 0 AND enabled = 1;'
+   [i] Number of exact allowed domains: 0
num=0
+ [[ domainlist WHERE type = 0 AND enabled = 1 == \g\r\a\v\i\t\y ]]
+ echo -e '  [i] Number of exact allowed domains: 0'
+ gravity_Table_Count 'domainlist WHERE type = 2 AND enabled = 1' 'regex allowed filters'
+ local 'table=domainlist WHERE type = 2 AND enabled = 1'
+ local 'str=regex allowed filters'
+ local num
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp 'SELECT COUNT(*) FROM domainlist WHERE type = 2 AND enabled = 1;'
+ num=0
+ [[ domainlist WHERE type = 2 AND enabled = 1 == \g\r\a\v\i\t\y ]]
+ echo -e '  [i] Number of regex allowed filters: 0'
+ ret=0
+ [[ '' != true ]]
+ return 0
+ timeit gravity_optimize
+ local start_time end_time elapsed_time ret
  [i] Number of regex allowed filters: 0
++ date +%s%3N
+ start_time=1740318126205
+ gravity_optimize
+ local 'str=Optimizing database'
+ echo -ne '  [i] Optimizing database...'
  [i] Optimizing database...+ output='++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db_temp '\''PRAGMA analysis_limit=0; ANALYZE'\''
0'
+ status=0
+ [[ 0 -ne 0 ]]
+ echo -e '\r  [✓] Optimizing database'
+ ret=0
  [✓] Optimizing database
+ [[ '' != true ]]
+ return 0
+ timeit gravity_swap_databases
+ local start_time end_time elapsed_time ret
++ date +%s%3N
+ start_time=1740318126284
+ gravity_swap_databases
+ str='Swapping databases'
+ echo -ne '  [i] Swapping databases...'
  [i] Swapping databases...++ stat -f --format %a /etc/pihole
+ availableBlocks=2546909
++ stat --format %b /etc/pihole/gravity.db
+ gravityBlocks=200
+ oldAvail=false
+ '[' 2546909 -gt 400 ']'
+ '[' -f /etc/pihole/gravity.db ']'
+ oldAvail=true
+ cp /etc/pihole/gravity.db /etc/pihole/gravity_old.db
+ output='++ printf '\''.timeout 30000\nDROP TABLE IF EXISTS gravity;\nDROP TABLE IF EXISTS antigravity;\nVACUUM;\n'\''
++ pihole-FTL sqlite3 -ni /etc/pihole/gravity.db'
+ status=0
+ [[ 0 -ne 0 ]]
+ '[' '!' -d /etc/pihole/gravity_backups ']'
+ rotate_gravity_backup
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.9 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.9 /etc/pihole/gravity_backups/gravity.db.10
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.8 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.8 /etc/pihole/gravity_backups/gravity.db.9
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.7 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.7 /etc/pihole/gravity_backups/gravity.db.8
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.6 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.6 /etc/pihole/gravity_backups/gravity.db.7
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.5 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.5 /etc/pihole/gravity_backups/gravity.db.6
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.4 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.4 /etc/pihole/gravity_backups/gravity.db.5
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.3 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.3 /etc/pihole/gravity_backups/gravity.db.4
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.2 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.2 /etc/pihole/gravity_backups/gravity.db.3
+ for i in {9..1}
+ '[' -f /etc/pihole/gravity_backups/gravity.db.1 ']'
+ mv /etc/pihole/gravity_backups/gravity.db.1 /etc/pihole/gravity_backups/gravity.db.2
+ mv /etc/pihole/gravity.db /etc/pihole/gravity_backups/gravity.db.1
+ mv /etc/pihole/gravity.db_temp /etc/pihole/gravity.db
+ echo -e '\r  [✓] Swapping databases'
+ true
+ echo -e '  [✓] The old database remains available'
+ ret=0
  [✓] Swapping databases
  [✓] The old database remains available
+ [[ '' != true ]]
+ return 0
+ timeit gravity_Cleanup
+ local start_time end_time elapsed_time ret
++ date +%s%3N
+ start_time=1740318126700
+ gravity_Cleanup
+ local error=
+ str='Cleaning up stray matter'
+ echo -ne '  [i] Cleaning up stray matter...'
  [i] Cleaning up stray matter...+ rm '/etc/pihole/pihole.*.txt'
+ rm '/etc/pihole/*.tmp'
+ rm '/tmp/*.phgpb'
+ rm '/tmp/*.ph-non-domains'
+ [[ true == true ]]
+ for file in "${piholeDir}"/*."${domainsExtension}"
+ [[ ! /etc/pihole/listsCache/list.1.raw.githubusercontent.com.domains == *\/\e\t\c\/\p\i\h\o\l\e\/\*\.\d\o\m\a\i\n\s* ]]
+ rm -f '/etc/pihole/*.domains'
+ echo -e '\r  [✓] Cleaning up stray matter'
  [✓] Cleaning up stray matter
+ [[ -n '' ]]
+ ret=0
+ [[ '' != true ]]
+ return 0
+ echo ''
+ echo '  [✓] Done.'

  [✓] Done.

@yubiuser
Copy link
Member

Ok, were are exactly here where it fails

https://github.com/pi-hole/pi-hole/blob/567bb724b18bf174f033d0b8b289cc44a5e9c8eb/gravity.sh#L540-L548


Your permission look right.

chris@T14Gen5:~$ docker exec pihole ls -l /etc/pihole
total 7768
-rw-rw---- 1 pihole pihole      65 Feb 19 19:44 adlists.list
-rw-r----- 1 pihole pihole      44 Feb 23 13:53 cli_pw
drwxr-xr-x 2 pihole pihole    4096 Feb 23 12:31 config_backups
-rw-rw---- 1 pihole pihole       0 Feb 19 19:42 dhcp.leases
-rw-rw---- 1 pihole pihole    5209 Feb 23 12:31 dnsmasq.conf
-rw-rw---- 1 pihole pihole 7606272 Feb 19 19:42 gravity.db
drwxr-xr-x 2 pihole pihole    4096 Feb 19 19:42 gravity_backups
-rw-rw---- 1 pihole pihole   94208 Feb 19 19:42 gravity_old.db
drwxr-xr-x 2 pihole pihole    4096 Feb 19 19:42 hosts
drwxr-xr-x 2 pihole pihole    4096 Feb 19 19:42 listsCache
-rw-r--r-- 1 root   root       421 Feb 23 13:53 logrotate
drwxr-xr-x 2 pihole pihole    4096 Feb 19 19:42 migration_backup
-rw-r----- 1 pihole pihole   90112 Feb 23 12:32 pihole-FTL.db
-rw-r----- 1 pihole pihole   32768 Feb 23 13:53 pihole-FTL.db-shm
-rw-r----- 1 pihole pihole    8272 Feb 23 13:53 pihole-FTL.db-wal
-rw-rw---- 1 pihole pihole   54226 Feb 23 12:31 pihole.toml
-rw-rw---- 1 pihole pihole     713 Feb 19 19:42 tls.crt
-rw-rw---- 1 pihole pihole    1001 Feb 19 19:42 tls.pem
-rw-rw---- 1 pihole pihole     733 Feb 19 19:42 tls_ca.crt
-rw-r--r-- 1 pihole pihole     397 Feb 23 13:53 versions

Can you check the content/permission within the directory?

chris@T14Gen5:~$ docker exec pihole ls -lha /etc/pihole/listsCache
total 2.6M
drwxr-xr-x 2 pihole pihole 4.0K Feb 19 19:42 .
drwxr-xr-x 7 pihole pihole 4.0K Feb 23 13:53 ..
-rw-rw---- 1 pihole pihole 2.6M Feb 19 19:42 list.1.raw.githubusercontent.com.domains
-rw-rw---- 1 pihole pihole   69 Feb 19 19:42 list.1.raw.githubusercontent.com.domains.etag
-rw-rw---- 1 pihole pihole  106 Feb 19 19:42 list.1.raw.githubusercontent.com.domains.sha1

@mattforscale
Copy link
Author

No other files in the directory

pi@pihole:~/pihole/etc-pihole $ docker exec pihole ls -lha /etc/pihole/listsCache
total 8.0K
drwxr-xr-x 2 pihole pihole 4.0K Feb 23 13:23 .
drwxrwxr-x 7 pihole pihole 4.0K Feb 23 13:42 ..

@rdwebdesign
Copy link
Member

Did you try to test the container without any volumes? If you didn't, please try it.

@mattforscale
Copy link
Author

I get a similar error when starting the container via docker run with no attached volume.

docker run --name pihole_test --net=host --restart=unless-stopped --cap-add=NET_ADMIN pihole/pihole:2025.02.4
  [i] Setting up user & group for the pihole user
  [i] PIHOLE_UID not set in environment, using default (1000)
  [i] PIHOLE_GID not set in environment, using default (1000)

  [i] Starting FTL configuration
  [i] No DNS upstream set in environment or config file, defaulting to Google DNS
  [i] No password set in environment or config file, assigning random password: RAJ7cCib
  [i] Starting crond for scheduled scripts. Randomizing times for gravity and update checker

  [i] Ensuring logrotate script exists in /etc/pihole

  [i] Gravity migration checks
  [i] No adlist file found, creating one with a default blocklist
  [i] /etc/pihole/gravity.db does not exist (Likely due to a fresh volume). This is a required file for Pi-hole to operate.
  [i] Gravity will now be run to create the database
  Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp.
  [✗] Migrating the list's cache directory to new location
sed: /etc/pihole/listsCache/*.sha1: No such file or directory
  [i] Creating new gravity database
  [i] Migrating content of /etc/pihole/adlists.list into new database
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...

  [✓] Preparing new gravity database
  [✓] Creating new gravity databases
  [✓] Pulling blocklist source list into range
  [i] Using libz compression

  [✗] Unable to write to /etc/pihole/listsCache
      Please run pihole -g as root

  [✓] Building tree
  [i] Number of gravity domains: 0 (0 unique domains)
  [i] Number of exact denied domains: 0
  [i] Number of regex denied filters: 0
  [i] Number of exact allowed domains: 0
  [i] Number of regex allowed filters: 0
  [✓] Optimizing database
  [✓] Swapping databases
  [✓] The old database remains available
  [✓] Cleaning up stray matter

  [✓] Done.

  [i] pihole-FTL pre-start checks
  [i] Setting capabilities on pihole-FTL where possible
  [i] Applying the following caps to pihole-FTL:
        * CAP_CHOWN
        * CAP_NET_BIND_SERVICE
        * CAP_NET_RAW
        * CAP_NET_ADMIN

  [i] Starting pihole-FTL (no-daemon) as pihole

  [i] Version info:
      Core version is v6.0.3 (Latest: v6.0.4)
      Web version is v6.0.1 (Latest: v6.0.1)
      FTL version is v6.0.2 (Latest: v6.0.2)

2025-02-23 17:45:14.145 UTC [149M] INFO: ########## FTL started on pihole! ##########

@Jisagi
Copy link

Jisagi commented Feb 26, 2025

I had the exact same problem, using the docker version (2025.02.5). It did solve itself after updating to the now latest version 2025.02.6. Now it works again in the ui.
I did get it to work in the older version as well though, but only when manually running it with forced root permissions (sudo -u root docker exec -t pihole pihole -g).

@mattforscale
Copy link
Author

Thanks. Unfortunately neither of those options worked for me. My next step is to try upgrading Docker to see if that helps.

@mattforscale
Copy link
Author

mattforscale commented Feb 27, 2025

Thanks. Unfortunately neither of those options worked for me. My next step is to try upgrading Docker to see if that helps.

Upgrade did not work either. I tried creating a small test shell script to check whether the directory is writable, print an error if its not, and then attempt to add the file anyway. In this case, the directory shows as not writable however I'm still able to write to it. So gravity is failing because it's being told it can't write to listsCache even though it can.

pi@pihole:~/pihole/etc-pihole $ docker exec pihole bash /etc/pihole/test.sh /etc/pihole/listsCache
Error: Directory '/etc/pihole/listsCache' is not writable.
Successfully created test_file.txt in /etc/pihole/listsCache
pi@pihole:~/pihole/etc-pihole $ docker exec pihole ls -l /etc/pihole/listsCache
total 0
-rw-r--r-- 1 root root 0 Feb 27 12:13 test_file.txt

@yubiuser
Copy link
Member

Same issue reported and linked PR to fix the issue at #1767


It's really strange that the directory is marked as not writable but you're still able to write to it.

@yubiuser
Copy link
Member

drwxr-xr-x 2 pihole pihole 4096 Feb 19 19:42 listsCache

Try to set the write permission of 'group' as well and see if it's working then
drwxrwxr-x 2 pihole pihole 4.0K Feb 28 12:33 listsCache

@mattforscale
Copy link
Author

Same issue reported and linked PR to fix the issue at #1767

It's really strange that the directory is marked as not writable but you're still able to write to it.

This worked. I'm back in business!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants