EPUB Error: Invalid or Missing mimetype File

PKG-006: the mimetype file must be the first file in the OCF ZIP Container. Or: PKG-007: mimetype entry has wrong media type or content

What causes this error?

Every EPUB ZIP archive must begin with a plain text file named mimetype containing exactly the string application/epub+zip — no leading or trailing whitespace, no byte-order mark, and no newline at the end. This file must also be stored without compression (using ZIP's "stored" method rather than "deflate") as the very first entry in the archive. Reading systems use it as a magic identifier to confirm the file is an EPUB before parsing any XML. Errors occur when the mimetype file is missing, placed inside a subfolder instead of at the archive root, contains extra characters or a trailing newline, is compressed rather than stored, or is not the first entry in the ZIP because another file was added before it during re-archiving. The most common cause is re-saving an EPUB through a general-purpose ZIP tool, which compresses all files and does not control entry order.

How to fix it

  1. Unzip your EPUB and confirm a file named exactly mimetype (no extension) exists at the root — not inside any subfolder. Its content must be exactly the 20-character string application/epub+zip with no spaces, newline, or trailing characters.
  2. If the file is missing or contains incorrect content, create it using a plain text editor, type application/epub+zip, and save as UTF-8 without BOM. Verify the file size is exactly 20 bytes.
  3. When repacking the EPUB ZIP, the mimetype file must be added first using the "stored" (no compression) method. From the command line: zip -X -0 yourbook.epub mimetype first, then add all other files with zip -rX yourbook.epub META-INF OEBPS.
  4. Do not use macOS Finder Compress, Windows Explorer Send to Compressed Folder, or standard ZIP utilities to create or repack an EPUB — they do not control compression level per file or file order. Use Sigil or Calibre's Export function instead.
  5. Re-validate with EPUBCheck to confirm the mimetype is the first, uncompressed entry in the archive.

Common questions

Why must the mimetype file be first and uncompressed?

The EPUB OCF (Open Container Format) specification requires it so reading systems can identify the file type by reading the first few bytes of the ZIP archive without fully decompressing it — the same principle as image magic bytes. If it's compressed or in the wrong position, a reader can't confirm the file is an EPUB before loading it.

Does this error cause my EPUB to be rejected by KDP or Apple Books?

Most platforms validate the mimetype as a pre-check before any content inspection. KDP may accept the upload but flag it with a warning; Apple Books and IngramSpark typically reject the file outright when the OCF container validation fails.

Check your EPUB before uploading

The free EPUB Validator catches structure, metadata, and navigation errors — no signup, no Java, runs in the browser.

Validate Your EPUB Free →

Building your EPUB correctly from the start prevents most of these errors before they happen. See the EPUB formatting guide for the full workflow: manuscript cleanup, TOC, front matter, EPUB 3.0 generation, and validation.

Common EPUB errors: Missing or invalid container.xml

Platform rejection guides: Why IngramSpark rejects books, Why Apple Books rejects ebooks