# Pulseaudio control not working in exec-node

**URL:** <https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982>\
**Category:** General\
**Created:** [14 September 2024 17:04 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982 "2024-09-14T17:04:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bitfriemler22](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bitfriemler22/32/94516_2.png) [@Bitfriemler22](https://discourse.nodered.org/u/Bitfriemler22)\
**Post date:** [14 September 2024 17:04 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/1 "2024-09-14T17:04:39Z")

</div>

Hi community,  
this is my first thread here!  
My hardware is a PI zero W + bullseye with a ugreen DABBoard (I2S) and blurtooth spekers.  
The installation I use works great and using CLI commands radio is playing from the speakers.  
Also setting the DABBoard active and tuning to some channel is fine using "exec"-node.  
The issue comes with the command for pulseaudio I'd like to send through another "exec"-node:  
arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16\_LE | paplay  
This is the error message:  
Verbindungsfehler: Verbindung verweigert  
pa\_context\_new() fehlgeschlagen: Verbindung verweigert

Basically: connection refused...

I tried with Nodered 3 and 4, Bullseye and Bookworm all bring the same error message.  
I already tried a lot of suggestions but the correct was not on the list yet 😉  
Hope to find support here, thanks.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 September 2024 19:40 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/2 "2024-09-14T19:40:01Z")

</div>

Welcome to the forum @Bitfriemler22

What OS are you using?

Edit: Also, how did you install node red and how do you run it?

---

<div class="post-metadata">

**Author:** ![Bitfriemler22](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bitfriemler22/32/94516_2.png) [@Bitfriemler22](https://discourse.nodered.org/u/Bitfriemler22)\
**Post date:** [15 September 2024 09:50 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/3 "2024-09-15T09:50:26Z")

</div>

Thank you Colin.  
My OS is  
...  
cat /etc/os-release  
PRETTY\_NAME="Raspbian GNU/Linux 11 (bullseye)"  
NAME="Raspbian GNU/Linux"  
VERSION\_ID="11"  
VERSION="11 (bullseye)"  
VERSION\_CODENAME=bullseye  
ID=raspbian  
ID\_LIKE=debian  
...

For the installation I followed the standard procedure described here: [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi)

For my purpose NR shall automatically start at boot. So I used:  
...  
sudo systemctl enable nodered.service  
...  
But if I start NR as user 'pi' there is no issue with running the exec-node.  
I suspect it has to do with certain rights (root vs user)?!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 September 2024 16:11 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/4 "2024-09-15T16:11:03Z")

</div>

> [@Bitfriemler22](#):
>
> I suspect it has to do with certain rights (root vs user)?!

It should not be running node-red as root when you run it as a service. You can check by running `whoami` in an exec node. The difference is probably to do with the fact that when you run node red directly from the command line you are already running in a login shell, with all the environment etc that goes with that.

Googling suggests this might work  
`arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16_LE | XDG_RUNTIME_DIR=/run/user/1000 paplay`  
but I won't be surprised if it is not that. It can be extremely difficult to solve this sort of problem.

---

<div class="post-metadata">

**Author:** ![Bitfriemler22](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bitfriemler22/32/94516_2.png) [@Bitfriemler22](https://discourse.nodered.org/u/Bitfriemler22)\
**Post date:** [15 September 2024 16:21 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/5 "2024-09-15T16:21:00Z")

</div>

Wow, very impressed!  
whoami gave "pi"  
Yor suggestion to add "XDG\_..." was direct hit!  
I tried this before but not with the uid but with username 'pi' which was not ideal ;-).  
Solved, great, thank you very much!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 September 2024 16:45 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/6 "2024-09-15T16:45:08Z")

</div>

Excellent.  
Can you mark my previous post as the solution please?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 September 2024 16:45 UTC](https://discourse.nodered.org/t/pulseaudio-control-not-working-in-exec-node/90982/7 "2024-09-29T16:45:45Z")

</div>

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