This is a common error in SharePoint that has multiple possible causes. The full error message that you get when going to the Managed Metadata Service Application in Central Admin is:
The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator.
In my particular case it was related to Registry permission. In the ULS we found this corresponding error message:
Error encountered in background cache check System.Security.SecurityException: Requested registry access is not allowed.
Of course SharePoint does not tell you which registry key it is trying to access (where’s the fun in that, right?).
The key it is trying to access is HKLM\SOFTWARE\Microsoft\Office Server\15.0. You can use the Process Monitor tool to work this out.
Normally the local groups WSS_ADMIN_WPG and WSS_WPG are given access to this key, but for some reasons that was not the case in our particular scenario. I suspect this was caused by a recent installation of a service pack/cumulative update.
We fixed this by manually granting the Read permission to the WSS_WPG group (after cross-referencing with another SharePoint instance). The WSS_ADMIN_WPG group should be granted the Read permission, with additional advanced permissions as shown below.
It seems that there are other ways to reapply these permissions, including Initialize-SPResourceSecurity and psconfig.exe -cmd secureresources. As this was a Dev server however, we didn’t spend time to investigate further.