I am running pulseaudio -D to start pulseaudio as a daemon, then running sudo bluetoothctl, connect to connect to the bluetooth speaker (it has already been paired). When I do this in X11 with a screen attached, it works fine, but when I do it in the terminal, it doesn't. I get the seemingly common error "Failed to connect: org.bluez.Error.Failed".
I get the same results as the post here: Connecting a headless Pi Zero W to a bluetooth speaker when pairing to it for the first time - it pairs, then connects for a small amount of time, then disconnects, and gives the org.bluez.Error.Failed any time I try to connect after that.
Any help would be greatly appreciated!