How to Stop Ubuntu from Automatically Changing the Default Audio Device

The Audio Hijack

Ubuntu utilizes a sound server (typically PulseAudio or PipeWire) to manage audio inputs and outputs. By default, this system is designed to automatically switch the default audio device whenever it detects new hardware. If you are listening to music on your desktop speakers and suddenly plug in a USB headset or connect a Bluetooth earpiece, Ubuntu will immediately hijack the audio stream and route it to the new device. While this plug-and-play behavior is often convenient, it is infuriating if you simply plugged your headset in to charge it, or if you prefer to manually control your audio routing for specific applications like OBS Studio or Discord.

Locking the Sound Server

To retain total control over your audio routing and stop Ubuntu from automatically changing the default audio device when you plug something in, you must modify the underlying sound server’s configuration file.

This cannot be done via the standard graphical settings menu. Open your terminal by pressing Ctrl+Alt+T. You need to edit the PulseAudio configuration (this applies even if your system uses PipeWire with a Pulse audio translation layer). Type exactly: sudo nano /etc/pulse/default.pa and press Enter (provide your password). Scroll carefully through this file until you find a line that looks like this: load-module module-switch-on-connect. You need to comment this line out to disable it. Place a hash symbol (#) at the very beginning of the line, so it reads: #load-module module-switch-on-connect. Press Ctrl+O then Enter to save, and Ctrl+X to exit the nano editor. Finally, restart the sound server by typing: pulseaudio -k. Ubuntu will no longer automatically hijack your audio stream when new devices are connected.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.