[GH-ISSUE #1494] librespot device not visible to spotify client #678

Closed
opened 2026-02-27 19:31:54 +03:00 by kerem · 16 comments
Owner

Originally created by @lidense on GitHub (Apr 28, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1494

Hi,
I have installed librespot (via raspotify) on my raspberry pi zero 2W.
I can see the librespot device on my spotify official app but not on a spotify client (spotipy) that runs on the same pi zero and on the same network.
If I connect to the device with the official app and play some music from my PC on it then the device becomes visible to the spotify client too but it disappear again after reboot.
I've seen this bug reported but did not find a solution I tried all that was recommended (oauth with librespot --cache /var/cache/raspotify --oauth-port 0 -j), added, 0.0.0.0 apresolve.spotify.com etc.
My system did work before name/password was deprecated.
Please advise as I have spent hours trying to find a solution and cannot use my system anymore.
Thanks

Originally created by @lidense on GitHub (Apr 28, 2025). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1494 Hi, I have installed librespot (via raspotify) on my raspberry pi zero 2W. I can see the librespot device on my spotify official app but not on a spotify client (spotipy) that runs on the same pi zero and on the same network. If I connect to the device with the official app and play some music from my PC on it then the device becomes visible to the spotify client too but it disappear again after reboot. I've seen this bug reported but did not find a solution I tried all that was recommended (oauth with librespot --cache /var/cache/raspotify --oauth-port 0 -j), added, 0.0.0.0 apresolve.spotify.com etc. My system did work before name/password was deprecated. Please advise as I have spent hours trying to find a solution and cannot use my system anymore. Thanks
kerem 2026-02-27 19:31:54 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@photovoltex commented on GitHub (Apr 28, 2025):

From what you describe it sounds like it starts in zeroconf mode even tho you provide a cache with presumably stored credentials.

Could you provide a debug log (provide -v additionally when calling librespot) with the complete startup and connecting from a client? With that we might be able to help you :)

<!-- gh-comment-id:2836639593 --> @photovoltex commented on GitHub (Apr 28, 2025): From what you describe it sounds like it starts in zeroconf mode even tho you provide a cache with presumably stored credentials. Could you provide a debug log (provide `-v` additionally when calling librespot) with the complete startup and connecting from a client? With that we might be able to help you :)
Author
Owner

@lidense commented on GitHub (Apr 29, 2025):

do I have to disable zeroconf by putting : LIBRESPOT_DISABLE_DISCOVERY=off
in that case do I have to fill in LIBRESPOT_USERNAME and LIBRESPOT_PASSWORD (I thought that was deprecated) or is the credentials.json file in /var/cache/raspotify sufficient ?
Thanks

<!-- gh-comment-id:2839541132 --> @lidense commented on GitHub (Apr 29, 2025): do I have to disable zeroconf by putting : LIBRESPOT_DISABLE_DISCOVERY=off in that case do I have to fill in LIBRESPOT_USERNAME and LIBRESPOT_PASSWORD (I thought that was deprecated) or is the credentials.json file in /var/cache/raspotify sufficient ? Thanks
Author
Owner

@photovoltex commented on GitHub (Apr 29, 2025):

do I have to disable zeroconf by putting : LIBRESPOT_DISABLE_DISCOVERY=off

If the cache contains credentials it should use them on startup and skip zeroconf automatically. There should be no need to adjust that behavior.

in that case do I have to fill in LIBRESPOT_USERNAME and LIBRESPOT_PASSWORD (I thought that was deprecated) or is the credentials.json file in /var/cache/raspotify sufficient ?

The credentials.json is where the cached credentials are stored. If that exist it should start with those credentials. Username and password aren't supported anymore on desktop, so providing them will not help with the problem.

You could try to remove the cache. Maybe some data got stuck in an invalid state, or your spotify password changed at some point. And as previously mentioned a log would help, otherwise we might not be able to help you much more then general guesses what the issue might be.

<!-- gh-comment-id:2839584475 --> @photovoltex commented on GitHub (Apr 29, 2025): > do I have to disable zeroconf by putting : LIBRESPOT_DISABLE_DISCOVERY=off If the cache contains credentials it should use them on startup and skip zeroconf automatically. There should be no need to adjust that behavior. > in that case do I have to fill in LIBRESPOT_USERNAME and LIBRESPOT_PASSWORD (I thought that was deprecated) or is the credentials.json file in /var/cache/raspotify sufficient ? The `credentials.json` is where the cached credentials are stored. If that exist it should start with those credentials. Username and password aren't supported anymore on desktop, so providing them will not help with the problem. You could try to remove the cache. Maybe some data got stuck in an invalid state, or your spotify password changed at some point. And as previously mentioned a log would help, otherwise we might not be able to help you much more then general guesses what the issue might be.
Author
Owner

@lidense commented on GitHub (Apr 30, 2025):

I have purged raspotify and reinstalled it again. So no more credentials.json in the /var/cache/raspotify.
I still have the problem my spotify device (pigrrl1) is visible when I use the Official spotify app but inconsistently (only for a few minutes then disappears, sometimes there is another device called 'raspotify (raspberry pi) although I have replaced the default Librespot name with "pigrrl1" in /etc/raspotify/conf.
when I do: ps aux | grep librespot I get: root 427 0.0 2.1 45376 9360 ? Ssl 10:08 0:00 /usr/bin/librespot
pi 541 0.0 3.3 53788 14824 ? Ssl 10:08 0:00 /usr/bin/librespot --name raspotify (raspberrypi) --device-type speaker --backend alsa --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100
I don't see pigrrl1 in the lines above, I don't know why, I wonder if librespot is really reading my /etc/raspotify/conf or if it gets config somewhere else.
I am not calling librespot directly, so I don't know how to get the logs (raspotifyservice is calling it).
These are the lines of my spotipy app that should recognize the device:
... results = sp.devices()
DATASTORE.clearDevices()
for _, item in enumerate(results['devices']):
print("hello")
if "pigrrl1" in item['name']:
device = UserDevice(item['id'], item['name'], item['is_active'])
All this was working a few months ago before librespot deprecated authentification with name and password.
In summary I cannot see my device with my spotipy app, sometimes if I first connect to it with the official Spotify app then it becomes visible.
Please advise

<!-- gh-comment-id:2841580563 --> @lidense commented on GitHub (Apr 30, 2025): I have purged raspotify and reinstalled it again. So no more credentials.json in the /var/cache/raspotify. I still have the problem my spotify device (pigrrl1) is visible when I use the Official spotify app but inconsistently (only for a few minutes then disappears, sometimes there is another device called 'raspotify (raspberry pi) although I have replaced the default Librespot name with "pigrrl1" in /etc/raspotify/conf. when I do: ps aux | grep librespot I get: root 427 0.0 2.1 45376 9360 ? Ssl 10:08 0:00 /usr/bin/librespot pi 541 0.0 3.3 53788 14824 ? Ssl 10:08 0:00 /usr/bin/librespot --name raspotify (raspberrypi) --device-type speaker --backend alsa --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 I don't see pigrrl1 in the lines above, I don't know why, I wonder if librespot is really reading my /etc/raspotify/conf or if it gets config somewhere else. I am not calling librespot directly, so I don't know how to get the logs (raspotifyservice is calling it). These are the lines of my spotipy app that should recognize the device: ... results = sp.devices() DATASTORE.clearDevices() for _, item in enumerate(results['devices']): print("hello") if "pigrrl1" in item['name']: device = UserDevice(item['id'], item['name'], item['is_active']) All this was working a few months ago before librespot deprecated authentification with name and password. In summary I cannot see my device with my spotipy app, sometimes if I first connect to it with the official Spotify app then it becomes visible. Please advise
Author
Owner

@kingosticks commented on GitHub (Apr 30, 2025):

This project and support is for librespot but you're talking about the config file for raspotify and then also some Python thing (?) called spotipy? We cannot support other applications, please ask for help via their support channels and then escalate any librespot bugs to us here.

<!-- gh-comment-id:2841754860 --> @kingosticks commented on GitHub (Apr 30, 2025): This project and support is for librespot but you're talking about the config file for raspotify and then also some Python thing (?) called spotipy? We cannot support other applications, please ask for help via their support channels and then escalate any librespot bugs to us here.
Author
Owner

@lidense commented on GitHub (Apr 30, 2025):

I have read that librespot has similar issues of device not being visible that's why I asked the question here.

<!-- gh-comment-id:2842390811 --> @lidense commented on GitHub (Apr 30, 2025): I have read that librespot has similar issues of device not being visible that's why I asked the question here.
Author
Owner

@kingosticks commented on GitHub (Apr 30, 2025):

Do you have a link to an issue that sounds like this one?

I don't see pigrrl1 in the lines above, I don't know why, I wonder if librespot is really reading my /etc/raspotify/conf or if it gets config somewhere else.

This sounds relevant. But it's not a librespot issue, it's a raspotify issue. Can you resolve that first?

<!-- gh-comment-id:2842444174 --> @kingosticks commented on GitHub (Apr 30, 2025): Do you have a link to an issue that sounds like this one? > I don't see pigrrl1 in the lines above, I don't know why, I wonder if librespot is really reading my /etc/raspotify/conf or if it gets config somewhere else. This sounds relevant. But it's not a librespot issue, it's a raspotify issue. Can you resolve that first?
Author
Owner

@lidense commented on GitHub (Apr 30, 2025):

I am not using raspotify anymore, just librespot that I launched with this command: /usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100
and this is the output:
2025-04-30T21:17:07Z INFO librespot] librespot 0.6.0 383a6f6 (Built on 2025-01-17, Build ID: XfjjOkbm, Profile: release)
[2025-04-30T21:17:07Z TRACE librespot] Command line argument(s):
[2025-04-30T21:17:07Z TRACE librespot] v
[2025-04-30T21:17:07Z TRACE librespot] name "pigrrl1"
[2025-04-30T21:17:07Z TRACE librespot] device-type "speaker"
[2025-04-30T21:17:07Z TRACE librespot] backend "alsa"
[2025-04-30T21:17:07Z TRACE librespot] device "default"
[2025-04-30T21:17:07Z TRACE librespot] bitrate "160"
[2025-04-30T21:17:07Z TRACE librespot] disable-audio-cache
[2025-04-30T21:17:07Z TRACE librespot] enable-volume-normalisation
[2025-04-30T21:17:07Z TRACE librespot] volume-ctrl "linear"
[2025-04-30T21:17:07Z TRACE librespot] initial-volume "100"
[2025-04-30T21:17:07Z DEBUG librespot_core::session] new Session
[2025-04-30T21:17:07Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:42833
[2025-04-30T21:17:07Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Linear
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Type: Auto
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Pregain: 0.0 dB
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Threshold: -2.0 dBFS
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Method: Dynamic
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Attack: 5 ms
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Release: 100 ms
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Knee: 5 dB
[2025-04-30T21:17:07Z DEBUG librespot_playback::player] new Player [0]
[2025-04-30T21:17:07Z INFO librespot_playback::convert] Converting with ditherer: tpdf
[2025-04-30T21:17:07Z INFO librespot_playback::audio_backend::alsa] Using AlsaSink with format: S16
[2025-04-30T21:17:07Z DEBUG librespot_discovery] Pinged Avahi: Available
[2025-04-30T21:17:07Z TRACE librespot_discovery] Connected to Avahi
[2025-04-30T21:17:07Z DEBUG librespot_discovery] Commited zeroconf service with name pigrrl1
[2025-04-30T21:17:08Z INFO librespot_discovery] Published zeroconf service

....
my problem is that although a device called pigrrl1 is indeed visible in my spotify premium app, it disappears spontaneously after a few minutes and also this device is not visible to other spotify clients that I am using to interact with the Spotify Web API.
Please advise

<!-- gh-comment-id:2843319046 --> @lidense commented on GitHub (Apr 30, 2025): I am not using raspotify anymore, just librespot that I launched with this command: /usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 and this is the output: 2025-04-30T21:17:07Z INFO librespot] librespot 0.6.0 383a6f6 (Built on 2025-01-17, Build ID: XfjjOkbm, Profile: release) [2025-04-30T21:17:07Z TRACE librespot] Command line argument(s): [2025-04-30T21:17:07Z TRACE librespot] v [2025-04-30T21:17:07Z TRACE librespot] name "pigrrl1" [2025-04-30T21:17:07Z TRACE librespot] device-type "speaker" [2025-04-30T21:17:07Z TRACE librespot] backend "alsa" [2025-04-30T21:17:07Z TRACE librespot] device "default" [2025-04-30T21:17:07Z TRACE librespot] bitrate "160" [2025-04-30T21:17:07Z TRACE librespot] disable-audio-cache [2025-04-30T21:17:07Z TRACE librespot] enable-volume-normalisation [2025-04-30T21:17:07Z TRACE librespot] volume-ctrl "linear" [2025-04-30T21:17:07Z TRACE librespot] initial-volume "100" [2025-04-30T21:17:07Z DEBUG librespot_core::session] new Session [2025-04-30T21:17:07Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:42833 [2025-04-30T21:17:07Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Linear [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Type: Auto [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Pregain: 0.0 dB [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Threshold: -2.0 dBFS [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Method: Dynamic [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Attack: 5 ms [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Release: 100 ms [2025-04-30T21:17:07Z DEBUG librespot_playback::player] Normalisation Knee: 5 dB [2025-04-30T21:17:07Z DEBUG librespot_playback::player] new Player [0] [2025-04-30T21:17:07Z INFO librespot_playback::convert] Converting with ditherer: tpdf [2025-04-30T21:17:07Z INFO librespot_playback::audio_backend::alsa] Using AlsaSink with format: S16 [2025-04-30T21:17:07Z DEBUG librespot_discovery] Pinged Avahi: Available [2025-04-30T21:17:07Z TRACE librespot_discovery] Connected to Avahi [2025-04-30T21:17:07Z DEBUG librespot_discovery] Commited zeroconf service with name pigrrl1 [2025-04-30T21:17:08Z INFO librespot_discovery] Published zeroconf service .... my problem is that although a device called pigrrl1 is indeed visible in my spotify premium app, it disappears spontaneously after a few minutes and also this device is not visible to other spotify clients that I am using to interact with the Spotify Web API. Please advise
Author
Owner

@lidense commented on GitHub (Apr 30, 2025):

...if I click on the device with the official spotify app then the device becomes visible to the other spotify client (which is on my raspberry pi.

<!-- gh-comment-id:2843461522 --> @lidense commented on GitHub (Apr 30, 2025): ...if I click on the device with the official spotify app then the device becomes visible to the other spotify client (which is on my raspberry pi.
Author
Owner

@kingosticks commented on GitHub (May 1, 2025):

You are starting librespot without any credential information. In this mode, credentials are provided by a client when they see librespot advertising over zeroconf and connect to it. Librespot will not be visible to any clients that do not support zeroconf at this point. librespot then uses those passed credentials to log into your account, and other clients connected to your account can then also see librespot. I think this explains what you see. To make this work as you want again, I think you need to use librespot oauth login (and set credentials cache argument etc), so that librespot logs into your account on startup and all clients will be able to see it straight away.

<!-- gh-comment-id:2844201456 --> @kingosticks commented on GitHub (May 1, 2025): You are starting librespot without any credential information. In this mode, credentials are provided by a client when they see librespot advertising over zeroconf and connect to it. Librespot will not be visible to any clients that do not support zeroconf at this point. librespot then uses those passed credentials to log into your account, and other clients connected to your account can then also see librespot. I think this explains what you see. To make this work as you want again, I think you need to use librespot oauth login (and set credentials cache argument etc), so that librespot logs into your account on startup and all clients will be able to see it straight away.
Author
Owner

@lidense commented on GitHub (May 1, 2025):

@kingosticks
thanks for your feedback I tried to do as you suggested with /usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 --credentials myclientid:myclientsecret --credentials-cache /home/pi/mycredentials/credentials_cache.json
but got a message that librespot does not recognize the --credentials option

so I went back to rasotify
and did: sudo librespot --cache /var/cache/raspotify --oauth-port 0 -j
I did get the credentials.json file in /var/cache/raspotify
I disabled zero conf with LIBRESPOT_DISABLE_DISCOVERY=off
and commented out #LIBRESPOT_DISABLE_CREDENTIAL_CACHE=on
when I restart raspotify and look at the logs I get: ERROR librespot] Credentials are required if discovery an>
as if the credentials where not taken into account?
Thanks

<!-- gh-comment-id:2844522956 --> @lidense commented on GitHub (May 1, 2025): @kingosticks thanks for your feedback I tried to do as you suggested with /usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 --credentials myclientid:myclientsecret --credentials-cache /home/pi/mycredentials/credentials_cache.json but got a message that librespot does not recognize the --credentials option so I went back to rasotify and did: sudo librespot --cache /var/cache/raspotify --oauth-port 0 -j I did get the credentials.json file in /var/cache/raspotify I disabled zero conf with LIBRESPOT_DISABLE_DISCOVERY=off and commented out #LIBRESPOT_DISABLE_CREDENTIAL_CACHE=on when I restart raspotify and look at the logs I get: ERROR librespot] Credentials are required if discovery an> as if the credentials where not taken into account? Thanks
Author
Owner

@kingosticks commented on GitHub (May 1, 2025):

librespot does not recognize the --credentials option

Which is correct, it does not exist. Nor does --credentials-cache. Have you read the documentation at https://github.com/librespot-org/librespot/wiki/Options#headless-oauth yet? I had assumed you had, sorry. Have a read of that and then try:

/usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 --cache /var/cache/raspotify --enable-oauth --oauth-port 0

You'll need to ensure you have permission to access /var/cache/raspotify.

<!-- gh-comment-id:2844567006 --> @kingosticks commented on GitHub (May 1, 2025): > librespot does not recognize the --credentials option Which is correct, it does not exist. Nor does `--credentials-cache`. Have you read the documentation at https://github.com/librespot-org/librespot/wiki/Options#headless-oauth yet? I had assumed you had, sorry. Have a read of that and then try: ``` /usr/bin/librespot -v --name pigrrl1 --device-type speaker --backend alsa --device default --bitrate 160 --disable-audio-cache --enable-volume-normalisation --volume-ctrl linear --initial-volume 100 --cache /var/cache/raspotify --enable-oauth --oauth-port 0 ``` You'll need to ensure you have permission to access /var/cache/raspotify.
Author
Owner

@lidense commented on GitHub (May 1, 2025):

I am going to try. I have another issue I have a bluetooth speaker on my raspberry and I think it works via pulseaudio which runs in usermode I have the impression librespot runs as root, is there a way to run it in user mode so that it can access my pulseaudio and my bluetooth speaker?

<!-- gh-comment-id:2844661361 --> @lidense commented on GitHub (May 1, 2025): I am going to try. I have another issue I have a bluetooth speaker on my raspberry and I think it works via pulseaudio which runs in usermode I have the impression librespot runs as root, is there a way to run it in user mode so that it can access my pulseaudio and my bluetooth speaker?
Author
Owner

@kingosticks commented on GitHub (May 1, 2025):

librespot is happy to run under any user. Raspotify makes the arbitrary (and bad) decision to run it as root.

<!-- gh-comment-id:2844696898 --> @kingosticks commented on GitHub (May 1, 2025): librespot is happy to run under any user. Raspotify makes the arbitrary (and bad) decision to run it as root.
Author
Owner

@lidense commented on GitHub (May 1, 2025):

@ kingosticks
It works!!!!
I added --disable-discovery to the command you suggested otherwise there was conflict with zeroconf,
than created a librespot.service that is lauched at boot.
And it works, i can now again connect to my bluetooth speaker on my raspberry and select and play playlists with a simple python script based spotify client.
I had spent hours trying to find a solution.
Thanks so much.

<!-- gh-comment-id:2844849950 --> @lidense commented on GitHub (May 1, 2025): @ kingosticks It works!!!! I added --disable-discovery to the command you suggested otherwise there was conflict with zeroconf, than created a librespot.service that is lauched at boot. And it works, i can now again connect to my bluetooth speaker on my raspberry and select and play playlists with a simple python script based spotify client. I had spent hours trying to find a solution. Thanks so much.
Author
Owner

@roderickvd commented on GitHub (May 3, 2025):

Marking as invalid because this turned out to be a configuration issue.

<!-- gh-comment-id:2848773254 --> @roderickvd commented on GitHub (May 3, 2025): Marking as `invalid` because this turned out to be a configuration issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#678
No description provided.