Systemd service is unable to connect to pulse audio


I am trying to run an application via systemd. This application tries to consume the audio system to emit some sounds.

When i run it from a terminal under my (current) user, everything works fine, although, when i configure it to run via systemd, it fails to connect to the pulse audio service and the sounds are not emitted.

This is my error message:
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

The underlying library to enable sounds is GitHub - faiface/beep: A little package that brings sound to any Go application. Suitable for playback and audio-processing.

The unit is
Description=Cucumber service.



$ groups mh-cbon
mh-cbon : mh-cbon lp docker

I tried to set the unit group as audio, that did not fix the problem. I would like not to have to add my user to audio group, if that would solve the issue.

Any idea what is going on ?

thank you for your help and inputs, it is appreciated.

What happens when you try to start it as a user service, e.g. systemctl --user start name.service


hi @ersen

Do you mean to install the service under /etc/systemd/user or $HOME/.config/systemd/user rather than /etc/systemd/system ?

The command sudo systemctl --user start cucumber.service failed with Failed to connect to bus: Aucun fichier ou dossier de ce type (ie: no file or folder of this type)

well done @ersen, for somewhat reason running it under user services made the job.

1 Like

I am not sure about /etc/systemd/user but the services I have started with systemctl --user is placed in /usr/lib/systemd/user, on my system.

1 Like

FTR, I placed it under $HOME/.config/systemd/user

I don’t know either = ) though it works and that is great.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.