Wireguard intent - "Not allowed [...] app is in background"

2,944 views
Skip to first unread message

a b

unread,
Jan 10, 2021, 10:49:00 AM1/10/21
to Automate

Hello all,

I'm using Automate to connect to Wireguard VPN. The connection is triggered using the Broadcast send block with these parameters:
Action: com.wireguard.android.action.SET_TUNNEL_UP
Extras: {"tunnel": "tunnel name"}

This works most of the time. Unfortunately sometimes the tunnel is not established but a toast message is posted to the screen:
Not allowed to start service Intent { cmp=com.wireguard.android/.backend.GoBackend$VpnService }: app is in background uid UidRecord{c280b63 u0a255 CEM  idle change:cached procs:1 seq(0,0,0)}

This looks like some problem on the Wireguard side, but is there anything that can be done in Automate to prevent it?

a b

unread,
Jan 10, 2021, 10:53:10 AM1/10/21
to Automate
Forgot to mention - problem occurs on two Android 10 phones, Xiaomi and Honor.

Henrik "The Developer" Lindqvist

unread,
Jan 10, 2021, 4:29:02 PM1/10/21
to Automate
Try enabling the Foreground flag, but it will likely cause the WireGuard app to crash with an ANR.

Chad Bowers

unread,
Sep 28, 2021, 1:59:36 AM9/28/21
to Automate
Hey there.  I'm having the same issue.  What's odd is, it was working perfectly fine.  Then randomly, the error message you describe started popping up.  For me it's constant.  It never actually connects to my wireguard.  I've got the permissions for the app (both in Wireguard - allow ext apps to control - and in Automate - control wireguard vpn) enabled...but still the error pops up.  I also tried the foreground as suggested by Henrik "The Developer" Lindqvist. 

Were you ever able to get around this error?

Chad Bowers

unread,
Sep 28, 2021, 2:21:55 AM9/28/21
to Automate
Something, I just discovered.  If I start the service in automate, then, after the error pops up, manually connect the Wireguard VPN, then turn on my wifi to connect to my named wifi network, the Automate service will turn off the Wireguard connection.  Then, as long as I don't manually manipulate anything else, if I lose Wifi on that network again, it WILL connect to Wireguard and not throw the error.  

I have no clue why this is, but it works.  So, basically it looks like for this to work, you need to manually connect to Wireguard the first time, then (assuming you'll have to do this after every reboot) after that it should continue to work.

On Sunday, January 10, 2021 at 8:49:00 AM UTC-7 a b wrote:

Henrik "The Developer" Lindqvist

unread,
Sep 28, 2021, 4:09:44 AM9/28/21
to Automate
Last time i checked, the problem was that the WireGuard app, or at least the Broadcast receiver listening for external commands, wasn't upgraded to work with Android 8+, causing the failure in OP.
Anyhow, there's nothing Automate can do about it.

Andreas

unread,
Jun 5, 2022, 12:57:59 AM6/5/22
to Automate
Try to disable Accu-Optimation for WireGuard. Seems to work for me.
Reply all
Reply to author
Forward
0 new messages