icloud Code 4040

How to Fix iCloud Error 4040

Diagnostic Procedures

  • 1 What Causes iCloud Error 4040
  • 2 Check Recently Deleted Files on iCloud
  • 3 Recover Files from iCloud.com
  • 4 Restore Files from Local Backups
  • 5 Prevent Accidental File Deletion

How to Fix iCloud Error 4040

iCloud error 4040 indicates that a file or folder expected by your device could not be found in iCloud. You’ll see “The requested file could not be found (Error 4040).”


Step 1: What Causes iCloud Error 4040

  • File deleted on another device and the deletion synced across all devices
  • File removed via iCloud.com using the web interface
  • Shared folder access revoked by the owner
  • App uninstalled that stored data in iCloud, triggering automatic cleanup
  • iCloud Drive sync glitch causing a stale file reference
  • Account storage expired — Apple may remove data if iCloud+ payment lapses

Step 2: Check Recently Deleted Files on iCloud

iCloud retains deleted files for 30 days.

On macOS: Check Trash — files deleted from iCloud Drive go there. Right-click > Put Back.

On iPhone/iPad: Open Files > Browse > Recently Deleted and tap Recover.

On Windows: Check the Recycle Bin for the missing file and right-click > Restore.


Step 3: Recover Files from iCloud.com

  1. Open https://www.icloud.com and sign in
  2. Go to iCloud Drive > Recently Deleted
  3. Select the file(s) and click Recover

For other iCloud data, go to Account Settings > Advanced where you can recover:

  • Contacts — restore a previous contact list snapshot
  • Calendars — restore calendar and reminder data
  • Bookmarks — restore Safari bookmarks

Files deleted more than 30 days ago are permanently removed from iCloud.


Step 4: Restore Files from Local Backups

Using Time Machine (macOS):

  1. Open the folder where the file was originally stored
  2. Click Time Machine in the menu bar > Browse Time Machine Backups
  3. Navigate to a date before deletion and click Restore
# List available Time Machine snapshots
tmutil listlocalsnapshots /

Using File History (Windows): Right-click inside the folder > Restore previous versions > choose a version and click Restore.

Check offline device copies: If a device was powered off when the deletion synced, it may still have a local copy. Turn it on without Wi-Fi, copy the file to USB, then reconnect.


Step 5: Prevent Accidental File Deletion

  • Enable Time Machine (macOS) with an external drive for automatic backups of iCloud Drive files
  • Set up a local sync mirror:
# Add to crontab (crontab -e) for nightly backup
0 2 * * * rsync -av ~/Library/Mobile\ Documents/com~apple~CloudDocs/ ~/Backups/iCloudMirror/
  • Think before deleting — deletions sync across all devices instantly
  • Keep iCloud+ active — if your subscription lapses, data may be removed after a grace period
  • Check Recently Deleted regularly — files are only recoverable for 30 days

Tip: If you see error 4040 for a file you didn’t delete, check if a family member or shared folder participant removed it by reviewing the current state at https://www.icloud.com/iclouddrive.