How to fix “connection to pulseaudio failed”.
Hi, this one is for google and anybody else who runs in to this problem. AFAIK this is an original solution. I haven't seen it anywhere else, hopefully it will work for you.
I've seen debate on the web on whether or not you even need pavucontrol. Some people say it's unneeded and can just be deleted. Maybe on your system, but definitely not on mine.
I have a laptop and I switch between stationary and portable modes. In portable mode I use the built in analog speakers. In stationary mode I plug in to my tv and use its HDMI speakers. (Note, HDMI sound support is not default in Ubuntu 12.04 pulse audio and requires the installation of additional repos and packages.)
I use pavucontrol to easily switch between analog and HDMI sound configurations. Even though pulse audio makes reconfiguring my system much easier it does have some stability issues and will crash from time to time; which is why you're reading this now!
I have read and tried a lot of solutions to pulse audio crashes and some of them worked. But, they were all a major pain in the neck. This one is easy:
1) Delete ~/.pulse-cookie
2) Delete all contents of ~/.pulse EXCEPT the presets folder, if you have one. The “presets” folder saves any custom configurations you create for your equalizer, do not delete them. Deleting all other files will “turn off” your equalizer. It will need to be re-enabled after repairs are completed.
3) This part I picked up from the web: Go to /etc/pulse/client.conf and change “autospawn = now” to “autospawn = yes” (apparently now is not a valid option).
That's it, easy peasy you're done. No need to purge, reinstall, reconfigure, migrate to a new user profile or any other of the headache filled solutions I've found and tried from around the web. And all of your customized settings are still saved in the system, they just have to be turned back on instead of recreated from scratch.