Skip to content

Instantly share code, notes, and snippets.

@lukasender
Created February 18, 2020 13:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasender/302e775aeeb48f00a7839ff4880e493a to your computer and use it in GitHub Desktop.
Save lukasender/302e775aeeb48f00a7839ff4880e493a to your computer and use it in GitHub Desktop.
macOS Catalina: Kill Audio Service "coreaudiod"
function killSound() {
# log coreaudiod process stats
ps aux | grep -e '^_coreaudiod.*/usr/sbin/coreaudiod$'
# grab the coreaudiod pid, and kill it.
sudo kill -9 $(ps aux | grep -e '^_coreaudiod.*/usr/sbin/coreaudiod$' | awk '{print $2}')
# wait until restarted
sleep 5
# log coreaudiod process stats again: verify process ID has changed
ps aux | grep -e '^_coreaudiod.*/usr/sbin/coreaudiod$'
}
@lukasender
Copy link
Author

Readme

What does it do?

Find the process ID of coreaudiod process ("What Is “coreaudiod,” and Why Is It Running on My Mac?"), forcefully kill the process (requires sudo access).

This forces macOS to restart the service.

Why does this exist?

On a MacBook Pro 16" 2019, I've experienced sound issues quite frequently.

The sound driver seems to keep crashing/restarting randomly. Read more here https://twitter.com/lukasender/status/1229740894015938560

Restarting coreaudiod process seems to "fix" the problems.

How to use

In the simplest form, simply copy and execute the following command in a terminal:

sudo kill -9 $(ps aux | grep -e '^_coreaudiod.*/usr/sbin/coreaudiod$' | awk '{print $2}')

If you frequently experience sound problems like I did, then add the function to your .bashrc/.zshrc (don't forget to source the updated config - or start a new terminal session).
Then, run killSound as soon as you experience the sound issues again.


Tested on macOS Catalina 10.15.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment