[GH-ISSUE #1292] "Connection reset by peer" - possible solution #590

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

Originally created by @hamishfagg on GitHub (Jun 8, 2024).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1292

EDIT: Workaround detailed below. My first solution didn't work.

This isn't a bug. I may have figured out a solution to an issue commonly reported here and wanted to post this in case someone else runs into it:

I have been getting Connection reset by peer (os error 104) in the librespot logs for a while - it usually plays 0.5-1 song before stopping playback and throwing this error.

I have a Unifi Gateway Lite as my router and I just turned off "Suspicious Activity" monitoring in the gateway's security settings. Suddenly librespot can play multiple hours of music again without stopping.
Annoyingly the gateway doesn't log anything about killing this connection. But I am pretty sure this was the culprit for me.

More full logs for people searching github etc:

2024-05-21 06-10-59.779 [Error] (librespot_playback::player) Unable to load audio item: MercuryError
2024-05-21 06-10-59.779 [Error] (librespot_core::session) Connection reset by peer (os error 104)
2024-05-21 06-10-59.779 [Error] (librespot_connect::spirc) subscription terminated
2024-05-21 06-10-59.782 [Warn] (librespot) Spirc shut down unexpectedly
2024-05-21 06-11-00.054 [Warn] (librespot_core::apresolve) Ignoring blacklisted access point ap-gue1.spotify.com:4070
2024-05-21 06-11-00.054 [Warn] (librespot_core::apresolve) Ignoring blacklisted access point ap-gew4.spotify.com:80
2024-05-21 06-11-00.055 [Info] (librespot_core::session) Connecting to AP "ap-gae2.spotify.com:4070"
Originally created by @hamishfagg on GitHub (Jun 8, 2024). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1292 EDIT: Workaround detailed [below](https://github.com/librespot-org/librespot/issues/1292#issuecomment-2274657355). My first solution didn't work. ~~This isn't a bug. I may have figured out a solution to an issue commonly reported here and wanted to post this in case someone else runs into it:~~ ~~I have been getting `Connection reset by peer (os error 104)` in the librespot logs for a while - it usually plays 0.5-1 song before stopping playback and throwing this error.~~ ~~I have a Unifi Gateway Lite as my router and I just turned off "Suspicious Activity" monitoring in the gateway's security settings. Suddenly librespot can play multiple hours of music again without stopping. Annoyingly the gateway doesn't log anything about killing this connection. But I am pretty sure this was the culprit for me.~~ ~~More full logs for people searching github etc:~~ ``` 2024-05-21 06-10-59.779 [Error] (librespot_playback::player) Unable to load audio item: MercuryError 2024-05-21 06-10-59.779 [Error] (librespot_core::session) Connection reset by peer (os error 104) 2024-05-21 06-10-59.779 [Error] (librespot_connect::spirc) subscription terminated 2024-05-21 06-10-59.782 [Warn] (librespot) Spirc shut down unexpectedly 2024-05-21 06-11-00.054 [Warn] (librespot_core::apresolve) Ignoring blacklisted access point ap-gue1.spotify.com:4070 2024-05-21 06-11-00.054 [Warn] (librespot_core::apresolve) Ignoring blacklisted access point ap-gew4.spotify.com:80 2024-05-21 06-11-00.055 [Info] (librespot_core::session) Connecting to AP "ap-gae2.spotify.com:4070" ```
kerem 2026-02-27 19:31:25 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@hamishfagg commented on GitHub (Jun 8, 2024):

Closing as this isn't an issue with librespot - just wanted a solution documented.

<!-- gh-comment-id:2155823396 --> @hamishfagg commented on GitHub (Jun 8, 2024): Closing as this isn't an issue with librespot - just wanted a solution documented.
Author
Owner

@hamishfagg commented on GitHub (Jun 23, 2024):

Unfortunately this seems to have been a coincidence.
I have started having the same error again, and can't find a solution.

  • I've logged packets on my router and the connection reset is definitely coming from outside the network
  • I can't find any pattern for when this happens, other than it's always when librespot runs preload to load the next song
  • It doesn't seem to matter which spotify ap I use, or which port on the ap.

Just.. sometimes it will play for hours on end without issue. And other times it can't play a whole song with out kicking me off

<!-- gh-comment-id:2184930024 --> @hamishfagg commented on GitHub (Jun 23, 2024): Unfortunately this seems to have been a coincidence. I have started having the same error again, and can't find a solution. - I've logged packets on my router and the connection reset is definitely coming from outside the network - I can't find any pattern for when this happens, other than it's always when librespot runs `preload` to load the next song - It doesn't seem to matter which spotify ap I use, or which port on the ap. Just.. sometimes it will play for hours on end without issue. And other times it can't play a whole song with out kicking me off
Author
Owner

@JCBird1012 commented on GitHub (Jun 23, 2024):

Related - https://github.com/librespot-org/librespot/issues/1151.

<!-- gh-comment-id:2185268958 --> @JCBird1012 commented on GitHub (Jun 23, 2024): Related - https://github.com/librespot-org/librespot/issues/1151.
Author
Owner

@hamishfagg commented on GitHub (Aug 8, 2024):

Ok after testing for the last month or so, it seems like I've found a workaround.

I've set up a VPN to tunnel only connections to spotify through a server in the USA (don't think it matters but I picked a server in LA). For whatever reason, connections coming from the US don't seem to be disconnected on the spotify end like connections from new zealand are..

A pretty silly solution but it's been working since I set up the tunnel

<!-- gh-comment-id:2274657355 --> @hamishfagg commented on GitHub (Aug 8, 2024): Ok after testing for the last month or so, it seems like I've found a workaround. I've set up a VPN to tunnel only connections to spotify through a server in the USA (don't think it matters but I picked a server in LA). For whatever reason, connections coming from the US don't seem to be disconnected on the spotify end like connections from new zealand are.. A pretty silly solution but it's been working since I set up the tunnel
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#590
No description provided.