Unable to modify the volume with the keyboard Sometimes, when I connect an external set of headphones/speakers, I am unable to change the volume. When I press one the volume keys, I see the image below. 

Why does this happen? Interestingly, if I am playing music using software that has a volume control (e.g. Spotify or Youtube) I can still change the volume with the mouse using the application's volume bar. However, the system's volume bar is greyed out and can't change it either.
What worked for me: open up a Terminal window and run:

sudo killall coreaudiod


You may also need to run the following two commands right after:

sudo kextunload /System/Library/Extensions/AppleHDA.kext 
sudo kextload /System/Library/Extensions/AppleHDA.kext