Error: Invalid or corrupt peers.dat file

I’m getting the same issue, once peers.dat is deleted, and the system rebooted, everything works as it should.

Until peers.dat returns then the system fails, I think something weird is going on with the process that creates the file, and it’s getting corrupted at that stage.

To get around this, I saved the below script to delete the peers.dat file as soon as it’s created. I called the script “delete_peers.sh” and saved it within ./bitcoin/data/bitcoin. I then passed the script to nohup so that it’ll continue to run after I close the terminal.

#!/bin/bash
DIR="<insert dir here>"   # Replace with the actual path to the directory

while true; do
    FILE=$(inotifywait -q -e create --format "%w%f" "$DIR")
    if [[ "$FILE" == "$DIR/peers.dat" ]]; then
        rm "$FILE"
    fi
done

Off to bed, but hopefully, I’ll still have a fully synced node in the morning.

1 Like