The headphone jack on my MacBook Pro stopped working. It was working fine, then just spontaneously stopped while I was using external speakers plugged into the output jack. Now, neither speakers nor 3 different headphones have sound. The internal speaker on my MacBook Pro still works.
I've had similar issues and restarting coreaudio work for me. Run this in a terminal (you might be prompted for your password).
sudo pkill coreaudiod
If your curious
sudo is something used to run commands as administrator (SU-DO as in super user do) and
pkill sends signals to processes based on name, in this case
coreaudiod, which is the name of the coreaudio daemon process. When it gets a terminate signal sent by pkill it will terminate and then macOS will restart it again.
I had this same problem with my MacBook Pro 13" (mid-2009) running OS 10.6.8. Somewhere on the internet I found the answer. After plugging in the headphones and looking at the System Preferences/Sound, you may not see (in theis model) the option for Headphones, only for Internal Speaker. (Of course, you must first check that the audio port is selected for output, since this Mac has only a single port audio. Also, that the mute is not selected.) After seeing no Headphone option, put the Mac to sleep and wake it up again. Voila! Your headphones/external speakers will work.
Does anyone know what the permanent fix is for this problem?
Let me tell how I solved my problem (that was: internal speakers worked whereas the headphones plugged in didn't):
I plugged in the headphones.
I pressed the "F10/Sound OnOff" key on the keyboard
That was it! The headphones worked again.
But why? To my understanding the reason is that Apple attaches the sound-on-or-off-state to the current output device.
So switching off the sound while having plugged in the headphones makes the headphones be silent. Plug them off and you will hear the internal speakers. Plug them in again (after a minute or after half a year) and they still will be silent. Because YOU switched off the sound OF THE HEADPHONES (some months ago).
(It is the same the other way round. But in that case you probably would try the F10 button ...)
(Note: you can see this behaviour also with the checked or unchecked mute button in System Preferences > Sound > Output, as mentioned in a post above. Its state depends on the selected output device.)