Error 9815 occurs in Apple Inc. related software program. The error appears when iTunes or iPhone is not able to establish a secure connection with the server. It describes as "iTunes has encountered a problem and needs to be closed. We are sorry for the inconvenience."
It occurs due to a variety of factors commonly due to incorrect time & date, Corrupt download or incomplete installation of the software, corruption in Windows registry from a recent software related change, issues with the firewall, virus or malware infections, etc.
The most simple and commonly suggested solution is to reset the date and time or to check the date/time-related settings and then restart the system. This can be done by accessing time and date settings in control panel.
If the method mentioned above doesn't work then try reinstalling the iTunes program, this might fix the problem. If still, the problem persists, try repairing the registry entries associated with error 9815 in Run>>regedit. By now the problem would've been solved.
Another most common cause for this error is the windows firewall blocking the internet access to the program. This issue can be overcome by running the program in Administrator using Run As Administrator command.
The problem also exists if some malicious program accidently deletes the files associated with this program. Then run a full PC scan and reinstall the program. You can use free antivirus service for this. These methods can be used when the error is shown in iTunes software on your system.
For a MAC, if the firewall blocks then disable the firewall in OS X and run the program. If the host file blocks the iTunes store, then log in as administrator on your Mac, open the Terminal utility>>host file by typing " sudo nano/private/etc/hosts " and press return.
It requests a nonblank password so type your administrator password. The host file contains comments and default hostname mappings. Find an entry containing " apple.com", then add # and space. This resolves the problem.
For the same error code in an iPhone, navigate to Settings>General>Date & time>Set automatically. Then restart your iPhone and try signing in. This solves the issue.