Unable to load theme magento2

If you are one of those who are facing issue "Unable to load theme" while registering a new Magento theme.

You might be experiencing below errors even after creating a new Magento2 theme and properly placing all the necessary files registration.php and theme.xml.
  • 'theme' table in database does not show your theme entry.
  • Content > Design > Theme in admin panel does not show your newly created theme entry.
  • setup:static-content:deploy command stuck while processing your theme.
Well, these all are very frustrating even though the registration.php and theme.xml files are correct.

Solution:
The issue could be file permission of the theme files. Strange!
  1.  Login as Magento file system owner.
  2. Navigate to Magento2 installation location.
  3. Run below commands.
    chown -R :nginx .   
    (replace 'nginx' by your web server user group name)

    find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento
More about Magento2 file system permission and ownership at http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html#install-perms-set

The theme registration issue should be resolved when you access your Magento2 store and run static-content:deploy command. "Unable to load theme" should be gone from console now.