What Happens When a Torrent Piece Hash Fails?

When downloading files via the BitTorrent protocol, data integrity is continuously verified using cryptographic hash checks for individual file segments known as pieces. If a completed piece fails its hash check, the torrent client immediately discards the corrupted data, marks the piece as missing to re-download it from the swarm, and monitors or penalizes the peer responsible for sending the bad data.

Discarding the Corrupted Data

Every .torrent file or magnet link metadata contains a cryptographic hash (typically SHA-1, or SHA-256 in BitTorrent v2) for each piece of the total payload. Once a client finishes assembling all the smaller blocks that make up a piece, it computes the hash of the assembled data. If this generated hash does not match the reference hash in the metadata, the client considers the entire piece invalid and immediately purges it from memory and disk. The bad data is never written into the final assembled file.

Re-Queuing the Piece for Download

After deleting the corrupted piece, the torrent client changes that piece’s status back to unobtained or missing. The piece is placed back into the download queue, and the client sends new block requests to other available peers in the swarm. To prevent getting the same corrupted data repeatedly, most clients prioritize requesting the missing blocks from different, healthy seeders or leechers.

Peer Tracking and Penalization

Because bandwidth is wasted when a hash check fails, modern torrent clients track which specific peers contributed blocks to the failed piece. The client takes several defensive actions: