The error Load failed: 5: Input/output error when using launchctl load often occurs due to permission issues, corruption of the plist file, or the service already being loaded. Here's how to troubleshoot and resolve it:
1. Check File Permissions
Ensure the com.apple.screensharing.plist file has the correct permissions and ownership:
sudo ls -l /System/Library/LaunchDaemons/com.apple.screensharing.plist
The output should show:
- Owner:
root:wheel
- Permissions:
-rw-r--r-- (644)
If not, fix them with:
sudo chown root:wheel /System/Library/LaunchDaemons/com.apple.screensharing.plist
sudo chmod 644 /System/Library/LaunchDaemons/com.apple.screensharing.plist
2. Unload and Reload the Service
Sometimes the service is already loaded or stuck. Try unloading it first:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
Then reload it:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
3. Run launchctl bootstrap for Detailed Errors
The error message suggested running launchctl bootstrap as root for more context. Execute:
sudo launchctl bootstrap gui/$(id -u) /System/Library/LaunchDaemons/com.apple.screensharing.plist
This will show detailed errors (e.g., missing files, syntax issues in the plist).
4. Check System Logs
Inspect system logs for related errors:
log show --predicate 'process == "com.apple.screensharing" OR substring == "launchd"' --last 1h
Look for entries indicating why the service failed to load.
5. Ensure Screen Sharing is Enabled in System Settings
- Go to System Settings > General > Remote Management (or Sharing in older macOS versions).
- Enable Screen Sharing and ensure the service is properly configured.
6. Reinstall macOS (Last Resort)
If the plist file is corrupted, you may need to reinstall macOS:
- Back up your data.
- Use macOS Recovery (restart and hold
Command + R).
- Select Reinstall macOS (this won’t delete your files).
Common Causes:
- File Corruption: The plist might be damaged (reinstalling macOS can fix this).
- Permissions: Incorrect ownership or permissions on the plist file.
- Service Already Running: Unloading before reloading resolves conflicts.
- System Integrity Protection (SIP): Ensure SIP is enabled (though rare for this issue).
Let me know if you need further clarification!