Ffile2fix
Sign in Get started

Fix "End-of-central-directory signature not found" in unzip

End-of-central-directory signature not found.  Either this file is not a zipfile, or it constitutes one disk of a multi-part archive.  In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive.

Every ZIP ends with an 'end of central directory' record that lists the files inside. unzip could not find it, which means the file is truncated, is not a ZIP at all, or is only one part of a split archive.

Also appears as: unzip: cannot find zipfile directory in one of backup.zip or backup.zip.zip, and cannot find backup.zip.ZIP, period. · zipfile.BadZipFile: File is not a zip file · ZipArchive::open() returned 19 (ZipArchive::ER_NOZIP: Not a zip archive) · java.util.zip.ZipException: zip END header not found

Common causes

  • An incomplete download or upload that cut off the end of the file
  • curl or wget saved a redirect, 403/404 page or login page instead of the archive
  • The file is a different format (tar.gz, 7z, RAR) with a .zip extension
  • It is one volume of a split archive (backup.z01, backup.z02, backup.zip)
  • The archive is still being written by another process or a backup job that failed
  • An archive over 4 GB was created by a tool without proper ZIP64 support

How to fix it

  1. Identify the file type. Run file backup.zip and head -c 100 backup.zip. HTML, JSON or 'gzip compressed data' means it is not a ZIP and needs a different tool or a proper download.
  2. Download with redirects followed. Use curl -fL -o backup.zip URL or wget URL. Without -L, curl saves a redirect response, and without -f it saves error pages as if they were the file.
  3. Check size and checksum. Compare ls -l backup.zip with the expected size and run sha256sum backup.zip against the published hash. A mismatch means fetch the file again.
  4. Merge split volumes. Put all parts in one folder and run zip -s 0 backup.zip --out single.zip, then unzip single.zip. For .zip.001 style parts use cat backup.zip.0* > backup.zip or 7-Zip.
  5. Rebuild the central directory. If the file is a truncated ZIP, run zip -FF backup.zip --out fixed.zip to scan local headers. Files cut off at the end will be missing or damaged.
  6. Use 7-Zip for large archives. For archives over 4 GB, try 7z x backup.zip, which handles ZIP64 well. Older unzip builds without ZIP64 support may fail on valid large archives.

Terminal

file backup.zip
curl -fL -o backup.zip https://example.com/backup.zip
sha256sum backup.zip
zip -s 0 backup.zip --out single.zip   # join split parts
zip -FF backup.zip --out fixed.zip     # rebuild truncated ZIP

How to stop it happening again

  • Use curl -fL or wget so failed downloads are not saved as files
  • Verify archives with unzip -t or a checksum before deleting the source
  • Do not move or download a backup until the job that writes it has finished
  • Keep all parts of split archives together

Frequently asked questions

What is the central directory?

It is an index stored at the end of a ZIP that lists every file, its size and its position. Because it is at the end, any truncation removes it first.

Why does Python say File is not a zip file?

zipfile.BadZipFile is Python's version of the same problem: it could not find the end-of-central-directory record. Check the file with the same steps as for unzip.

Will zip -FF recover everything?

It recovers entries whose local headers and data are intact. Anything after the point where the file was cut off is lost, so a fresh download is always preferable.