How to Stop Ubuntu Linux from Automatically Changing Audio Outputs

The Audio Output Roulette

A common and highly annoying issue in Ubuntu Linux occurs when you plug in a new device, such as a USB webcam with a built-in microphone, or a monitor via HDMI. The PulseAudio or PipeWire sound server immediately assumes you want to use this new device for all your audio and automatically switches your default input and output to it. This means your music suddenly stops playing from your speakers and starts playing from your monitor, or your high-quality desktop microphone is suddenly bypassed in favor of a terrible webcam mic during a video call.

How to Disable PulseAudio Auto-Switching

To stop Ubuntu from aggressively routing audio to newly connected hardware, you must edit the core configuration file of the PulseAudio sound server and disable the specific module responsible for this behavior.

1. Open your terminal application (Ctrl+Alt+T).

2. Open the main PulseAudio configuration file using a text editor with root privileges:

sudo nano /etc/pulse/default.pa

3. Scroll down through the file until you locate the following line of text:

load-module module-switch-on-connect

4. You need to comment out this line to disable the module. Add a hash symbol (#) to the very beginning of the line, so it looks exactly like this:

#load-module module-switch-on-connect

5. Save the file by pressing Ctrl+O, then Enter. Exit the nano editor by pressing Ctrl+X.

6. For the changes to take effect immediately, you must restart the PulseAudio server. Run the following command:

pulseaudio -k

The sound server will instantly kill itself and automatically restart using the new configuration. From now on, when you plug in a new HDMI cable or USB headset, your audio will continue playing through its current source without interruption. If you want to use the new device, you will simply have to click the volume icon in the top right corner of the screen and select it manually.

Get the best tech tips delivered straight to your inbox.

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