2023-09-11 00:13:51 -04:00
# Troubleshooting
2023-11-30 10:41:18 -05:00
This page is a collection of tips to solve problems you may encounter using Nix.
2023-09-11 00:13:51 -04:00
## What to do if a binary cache is down or unreachable?
2023-11-01 22:41:54 -04:00
Pass [`--option substitute false` ](https://nix.dev/manual/nix/2.18/command-ref/conf-file#conf-substitute ) to Nix commands.
2023-09-11 00:13:51 -04:00
2023-11-30 10:41:18 -05:00
## How to force Nix to re-check if something exists in the binary cache?
Nix keeps track of what's available in binary caches so it doesn't have to query them on every command.
2024-04-29 10:44:03 -04:00
This includes negative answers, that is, if a given store path cannot be substituted.
2023-11-30 10:41:18 -05:00
Pass the [`--narinfo-cache-negative-ttl` ](https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-narinfo-cache-negative-ttl ) option to set the cache timeout in seconds.
## How to fix: `error: querying path in database: database disk image is malformed`
2023-09-11 00:13:51 -04:00
2023-09-11 05:44:33 -04:00
This is a [known issue ](https://github.com/NixOS/nix/issues/1353 ).
2023-09-11 00:13:51 -04:00
Try:
```shell-session
$ sqlite3 /nix/var/nix/db/db.sqlite "pragma integrity_check"
```
2023-11-01 22:41:54 -04:00
Which will print the errors in the [database ](https://nix.dev/manual/nix/2.18/glossary#gloss-nix-database ).
2023-09-11 05:44:33 -04:00
If the errors are due to missing references, the following may work:
2023-09-11 00:13:51 -04:00
```shell-session
$ mv /nix/var/nix/db/db.sqlite /nix/var/nix/db/db.sqlite-bkp
$ sqlite3 /nix/var/nix/db/db.sqlite-bkp ".dump" | sqlite3 /nix/var/nix/db/db.sqlite
```
2023-11-30 10:41:18 -05:00
## How to fix: `error: current Nix store schema is version 10, but I only support 7`
2023-09-11 00:13:51 -04:00
2023-09-11 05:44:33 -04:00
This is a [known issue ](https://github.com/NixOS/nix/issues/1251 ).
2023-09-11 00:13:51 -04:00
2023-11-01 22:41:54 -04:00
It means that using a new version of Nix upgraded the SQLite schema of the [database ](https://nix.dev/manual/nix/2.18/glossary#gloss-nix-database ), and then you tried to use an older version Nix.
2023-09-11 05:44:33 -04:00
2024-01-05 12:50:50 -05:00
The solution is to dump the database, and use the old Nix version to re-import the data:
2023-09-11 00:13:51 -04:00
```shell-session
$ /path/to/nix/unstable/bin/nix-store --dump-db > /tmp/db.dump
$ mv /nix/var/nix/db /nix/var/nix/db.toonew
$ mkdir /nix/var/nix/db
$ nix-store --load-db < /tmp/db.dump
```
2023-11-30 10:41:18 -05:00
## How to fix: `writing to file: Connection reset by peer`
2023-09-11 05:44:33 -04:00
2023-11-01 22:41:54 -04:00
This may mean you are trying to import a too large file or directory into the [Nix store ](https://nix.dev/manual/nix/2.18/glossary#gloss-store ), or your machine is running out of resources, such as disk space or memory.
2023-09-11 00:13:51 -04:00
2023-11-01 22:41:54 -04:00
Try to reduce the size of the directory to import, or run [garbage collection ](https://nix.dev/manual/nix/2.18/command-ref/nix-collect-garbage ).