Error connecting to database /etc/pihole/gravity.db: Unable to open database: unable to open database file

Pihole v6 beta, on Proxmox Debian 10 as a container

Right after running "pihole - up" ()pdated all 3 FTL web and Core)
I got errors "Error connecting to database /etc/pihole/gravity.db: Unable to open database: unable to open database file"

I tried the following

pihole -g

Error: in prepare, no such table: info
[i] Neutrino emissions detected...
[i] Storing gravity database in /etc/pihole/gravity.db
[✓] Pulling blocklist source list into range
[i] No source list found, or it is empty

[✓] Preparing new gravity database
[i] Creating new gravity databases...
[✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
[✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

pihole -r


[i] Repair option selected
  [i] Performing reconfiguration, skipping download of local repos
  [✓] Resetting repository within /etc/.pihole...
  [✓] Resetting repository within /var/www/html/admin...
  [i] Checking for / installing Required dependencies for Pi-hole software...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for iputils-ping
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [✓] Checking for unzip
  [✓] Checking for libcap2-bin
  [✓] Checking for dns-root-data
  [✓] Checking for libcap2
  [✓] Checking for netcat-openbsd
  [✓] Checking for procps
  [✓] Checking for jq
  [✓] Checking for lshw
  [✓] Checking for bash-completion

  [✓] Checking for user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 architecture
  [i] Checksum of installed binary matches remote. No need to download!
  [✓] Installing scripts from /etc/.pihole

  [i] Installing configs from /etc/.pihole...

  [✓] Installing latest Cron script

  [i] Installing latest logrotate script...
        [i] Existing logrotate file found. No changes made.
  [✓] man pages installed and database updated
  [i] Testing if systemd-resolved is enabled
  [i] Systemd-resolved does not need to be restarted
Error: in prepare, no such table: info
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
Error: in prepare, no such table: info
  [✓] Deleting existing list cache
  [i] Neutrino emissions detected...
  [i] Storing gravity database in /etc/pihole/gravity.db
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

ls -lh /etc/pihole groups pihole

ls: cannot access 'groups': No such file or directory
ls: cannot access 'pihole': No such file or directory
/etc/pihole:
total 14M
-rw-rw---- 1 pihole pihole   65 Mar  6 19:11 adlists.list
-rw-rw---- 1 pihole pihole   65 Feb  1 00:35 adlists.list.old
drwxr-xr-x 2 pihole pihole 4.0K Mar  6 19:02 config_backups
-rw-rw---- 1 pihole pihole    0 Feb  1 00:16 custom.list.bck
-rw-rw---- 1 pihole pihole    0 Feb  1 00:16 dhcp.leases
-rw-rw---- 1 pihole pihole  651 Mar  6 19:37 dns-servers.conf
-rw-rw---- 1 pihole pihole 5.4K Mar  6 19:02 dnsmasq.conf
-rw-rw---- 1 pihole pihole   15 Feb  1 00:24 ftlbranch
-rw-rw---- 1 pihole pihole    0 Mar  6 18:49 gravity.db
-rw-r--r-- 1 pihole pihole 100K Mar  6 19:37 gravity.db_temp
drwxr-xr-x 2 pihole pihole 4.0K Feb  1 00:35 hosts
-rw-rw---- 1 pihole pihole  408 Mar  6 19:37 install.log
-rw-rw---- 1 pihole pihole   65 Feb 22 00:30 local.list
-rw-r--r-- 1 root   root    241 Feb  1 00:16 logrotate
-rw-rw---- 1 pihole pihole 3.0M Mar  6 19:18 macvendor.db
drwxr-xr-x 2 pihole pihole 4.0K Feb  1 00:16 migration_backup
-rw-rw---- 1 pihole pihole  146 Mar  6 19:02 pihole-FTL.conf.bck
-rw-rw-r-- 1 pihole pihole 9.6M Mar  6 19:37 pihole-FTL.db
-rw-rw-r-- 1 pihole pihole  32K Mar  6 20:04 pihole-FTL.db-shm
-rw-rw-r-- 1 pihole pihole 765K Mar  6 20:04 pihole-FTL.db-wal
-rw-rw---- 1 pihole pihole  46K Mar  6 19:02 pihole.toml
-rw-rw---- 1 pihole pihole  441 Mar  6 19:02 setupVars.conf.old
-rw-rw---- 1 pihole pihole  709 Feb  1 00:35 tls.crt
-rw-rw---- 1 pihole pihole  997 Feb  1 00:35 tls.pem
-rw-rw---- 1 pihole pihole  733 Feb  1 00:35 tls_ca.crt
-rw-rw---- 1 pihole pihole  375 Mar  6 19:13 versions

root@DC:/etc/pihole# pihole -v

Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-680-gf79a4046 (Latest: null)
    Branch is development-v6
    Hash is f79a4046 (Latest: f79a4046)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9c)

cd /etc/.pihole

git status

On branch development-v6
Your branch is up to date with 'origin/development-v6'.

nothing to commit, working tree clean

I see there is an update for Web

# pihole -v
Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-680-gf79a4046 (Latest: null)
    Branch is development-v6
    Hash is f79a4046 (Latest: 00304273)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9c) 

#pihole -up
  [✓] Update local cache of available packages
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for dialog
  [✓] Checking for ca-certificates

  [i] Checking for updates...
  [i] Pi-hole Core:     up to date
  [i] Web Interface:    update available
  [i] Checksum of installed binary matches remote. No need to download!
  [i] FTL:              up to date
  [i] Warning: You are using FTL from a custom branch (development-v6) and might be missing future releases.

  [i] Pi-hole Web Admin files out of date, updating local repo.
  [✓] Check for existing repository in /var/www/html/admin
  [✓] Update repo in /var/www/html/admin

  [i] If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'
  [i] Local version file information updated.

and again


# pihole -g
Error: in prepare, no such table: info
  [i] Neutrino emissions detected...
  [i] Storing gravity database in /etc/pihole/gravity.db
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.
root@DC:~# pihole -v
Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-682-g00304273 (Latest: null)
    Branch is development-v6
    Hash is 00304273 (Latest: 00304273)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9

This issue happened suddenly after the pihole update

https://tricorder.pi-hole.net/u2pnoASM/

Your gravity database is completely empty (no data, no tables, nothing).

Please, try to create a new database with pihole -g -r recreate and report the result.

1 Like

Yes it is empty, that is the issue.

There was activity before the error. so something happened to the database during "pihole -up"

pihole -g should be the only command that is run after an update...

root@p6beta:~# pihole -g -r recreate
[i] Recreating gravity database from migration backup.../opt/pihole/gravity.sh: line 848: popd: /root: Permission denied
root@p6beta:~# sudo pihole -g -r recreate
[i] Recreating gravity database from migration backup...rm: cannot remove '/etc/pihole/gravity.db': No such file or directory
/opt/pihole/gravity.sh: line 848: popd: /root: Permission denied

Do I have to just scrap this pihole?

This issues keeps happening on Beta 6.0 after an update, gravity.db vanished .

I have now 2 instances of Pihole Beta 6.0 with this same issue, One is a Raspberry Pi Zero, the second one is a Proxmox VM

pihole -v  
Core
    Version is v5.18.2-364-g7b19b650 (Latest: null)
    Branch is development-v6
    Hash is 7b19b650 (Latest: N/A)
Web
    Version is v5.19-754-g24977e86 (Latest: null)
    Branch is development-v6
    Hash is 24977e86 (Latest: N/A)
FTL
    Version is vDev-60b1a75 (Latest: null)
    Branch is development-v6
    Hash is 60b1a753 (Latest: N/A)
pihole -up
  [✓] Update local cache of available packages
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for dialog
  [✓] Checking for ca-certificates

  [i] Checking for updates...
fatal: unable to access 'https://github.com/pi-hole/pi-hole.git/': server certificate verification failed. CAfile: none CRLfile: none
  [i] Pi-hole Core:     up to date
fatal: unable to access 'https://github.com/pi-hole/web.git/': server certificate verification failed. CAfile: none CRLfile: none
  [i] Web Interface:    up to date
  [i] FTL binary already installed, verifying integrity...
  [✗] Remote binary is different, downloading...
  [i] FTL:              update available
  [i] Warning: You are using FTL from a custom branch (development-v6) and might be missing future releases.

  [i] FTL out of date, it will be updated by the installer.

  [✓] Root user check

        .;;,.
        .ccccc:,.
         :cccclll:.      ..,,
          :ccccclll.   ;ooodc
           'ccll:;ll .oooodc
             .;cll.;;looo:.
                 .. ','.
                .',,,,,,'.
              .',,,,,,,,,,.
            .',,,,,,,,,,,,....
          ....''',,,,,,,'.......
        .........  ....  .........
        ..........      ..........
        ..........      ..........
        .........  ....  .........
          ........,,,,,,,'......
            ....',,,,,,,,,,,,.
               .',,,,,,,,,'.
                .',,,,,,'.
                  ..'''.

  [i] SELinux not detected
  [✓] Update local cache of available packages

  [✗] Checking apt-get for upgraded packages
      Kernel update detected. If the install fails, please reboot and try again
  [i] Checking for / installing Required dependencies for OS Check...
  [✓] Checking for grep
  [✓] Checking for dnsutils
  [✓] Checking for binutils

  [✓] Supported OS detected
  [i] Checking for / installing Required dependencies for this install script...
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for dialog
  [✓] Checking for ca-certificates

  [i] Performing unattended setup, no dialogs will be displayed
  [i] Performing reconfiguration, skipping download of local repos
  [✓] Resetting repository within /etc/.pihole...
  [✓] Resetting repository within /var/www/html/admin...
  [i] Checking for / installing Required dependencies for Pi-hole software...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for iputils-ping
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [✓] Checking for unzip
  [✓] Checking for libcap2-bin
  [✓] Checking for dns-root-data
  [✓] Checking for libcap2
  [✓] Checking for netcat-openbsd
  [✓] Checking for procps
  [✓] Checking for jq
  [✓] Checking for lshw
  [✓] Checking for bash-completion

  [✓] Checking for user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 architecture
  [i] FTL binary already installed, verifying integrity...
  [✗] Remote binary is different, downloading...
  [✓] Downloading and Installing FTL
  [✓] Installing scripts from /etc/.pihole

  [i] Installing configs from /etc/.pihole...

  [✓] Installing latest Cron script

  [i] Installing latest logrotate script...
        [i] Existing logrotate file found. No changes made.
  [✓] man pages installed and database updated
  [i] Testing if systemd-resolved is enabled
  [i] Systemd-resolved does not need to be restarted
Error: in prepare, no such table: info
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
Error: in prepare, no such table: info
  [✓] Deleting existing list cache
  [i] Neutrino emissions detected...
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

  Unable to complete update, please contact Pi-hole Support

This is already hinting at a problem somewhere, I have not seen this before, but it seems your system certificate store may be empty/disfunctional somehow. This may or not prevent proper updating- your pihole -v output is also lacking remote versions.

This is definitely not the most recent commit 159be01e on development-v6 (published 5 days ago).

This already hints at a broken database, but not a non-existing one. We'll talk about this in the team in the background and come back to you!

1 Like

I have the exact same issue. Any help would be much appreciated

In which way "exact"ly the same? You are also getting the CAfile: none CRLfile: none error?

I have been trying to update gravity but it seems to have he same error.

pihole -v
Core
    Version is v5.18.3-510-g8e5ac2db (Latest: null)
    Branch is development
    Hash is 8e5ac2db (Latest: 112b9617)
Web
    Version is v5.21-984-gae728a16 (Latest: null)
    Branch is development
    Hash is ae728a16 (Latest: c689fdc7)
FTL
    Version is vDev-e558f79 (Latest: null)
    Branch is development
    Hash is e558f798 (Latest: 8b7a8432)
pihole -g
Error: in prepare, no such table: info
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

Another thing I tried

curl -sSL https://install.pi-hole.net | bash

  [✓] Root user check

        .;;,.
        .ccccc:,.




 Specify Upstream DNS Provider(s)
 Pi-hole Installation
 Pihole Installation
 Pi-hole Installation
 Pihole Installation














  [i] Using privacy level: 0
  [✓] Check for existing repository in /etc/.pihole
  [i] Update repo in /etc/.pihole...
  [✓] Update repo in /etc/.pihole

  [✓] Check for existing repository in /var/www/html/admin
  [✓] Update repo in /var/www/html/admin

  [i] Checking for / installing Required dependencies for Pi-hole software...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for iputils-ping
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [✓] Checking for unzip
  [✓] Checking for idn2
  [✓] Checking for libcap2-bin
  [✓] Checking for dns-root-data
  [✓] Checking for libcap2
  [✓] Checking for netcat-openbsd
  [✓] Checking for procps
  [✓] Checking for jq

  [✓] Checking for user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 processor
  [i] Checking for existing FTL binary...
  [i] Branch "development" is not available.
  [i] Use pihole checkout ftl [branchname] to switch to a valid branch.
  [✓] Installing scripts from /etc/.pihole

  [i] Installing configs from /etc/.pihole...
  [i] No dnsmasq.conf found... restoring default dnsmasq.conf...install: cannot stat '/etc/.pihole/advanced/dnsmasq.conf.original': No such file or directory
  [✓] No dnsmasq.conf found... restoring default dnsmasq.conf...
  [i] Installing /etc/dnsmasq.d/01-pihole.conf...install: cannot stat '/etc/.pihole/advanced/01-pihole.conf': No such file or directory
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
sed: can't read /etc/dnsmasq.conf: No such file or directory
  [i] Installing /etc/.pihole/advanced/06-rfc6761.conf...install: cannot stat '/etc/.pihole/advanced/06-rfc6761.conf': No such file or directory
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf

  [i] Installing sudoer file...install: cannot stat '/etc/.pihole/advanced/Templates/pihole.sudo': No such file or directory
grep: /etc/pihole/setupVars.conf: No such file or directory
  [i] Testing if systemd-resolved is enabled
  [i] Systemd-resolved does not need to be restarted
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
Error: in prepare, no such table: info
  [✓] Deleting existing list cache
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

he only thing that changed is the update to the recent Domains on list displays Error -2.
So this works :slight_smile:

The problem here is that if your gravity.db is broken, then there isn't much pihole -g could do anyway. We are sourcing the subscribed lists and everything else from this database.

Could you check if it is still a valid database by running

pihole-FTL sqlite3 /etc/pihole/gravity.db .schema

and posting the result here?