Can't edit settings.php in Drupal 7 - Premission Denied - Can't Write to File via Cpanel File Manager
As others have mentioned, you must set the permissions on the /sites/default folder. The default permissions are set to 0555, set them to 0755 for editing. Don't forget to restore the default values afterwards!