[Bug]: Both website and app display "Socket unable to connect" after setting up reverse proxy, but works fine #2752

Closed
opened 2026-04-25 00:10:13 +02:00 by adam · 2 comments
Owner

Originally created by @nc5432 on GitHub (May 7, 2025).

What happened?

I recently set up a reverse proxy to get https working. I am using nginx for it. After getting it set up, the web client permanently has a 'Socket unable to connect' message at the bottom of the screen. However, everything works normally and I am able to listen to audio books. I updated the address on the android app, and it too has some issues. It indicates that it is having an issue connecting to the server with the orange cloud icon, and clicking on it reveals the same message as above. However, everything still works fine. Login works, books load, timestamps sync. This only happens when I am using the reverse proxy.

What did you expect to happen?

Audiobookshelf should not display an error when running behind an https reverse proxy

Steps to reproduce the issue

  1. Install nginx. I am not using the docker version, and am running it on linux mint
  2. Install audiobookshelf. I am using the docker compose version and running 2.21.0
  3. Configure a reverse proxy to point to audiobookshelf. I have tried both of the following code blocks, and each produce the same result:
server{
    listen 443 ssl;
    listen [::]:443 ssl;
    
    ssl_certificate {PATH_TO_CERT};
    ssl_certificate_key {PATH_TO_KEY};

    server_name url.domain.com;
    location / {
        proxy_pass http://localhost:13378;
    }
}
server{
    listen 443 ssl;
    listen [::]:443 ssl;

    ssl_certificate {PATH_TO_CERT};
    ssl_certificate_key {PATH_TO_KEY};

    server_name url.domain.com;
    location / {
        proxy_pass http://localhost:13378;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
  1. Connect to the audiobookshelf server through the reverse proxy.

Audiobookshelf version

2.21.0

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Other (list in "Additional Notes" box)

Logs

2025-05-06 19:24:39.765

INFO

=== Starting Server ===

2025-05-06 19:24:39.765

INFO

[Server] Init v2.21.0

2025-05-06 19:24:39.765

INFO

[Server] Node.js Version: v20.19.1

2025-05-06 19:24:39.765

INFO

[Server] Platform: linux

2025-05-06 19:24:39.766

INFO

[Server] Arch: x64

2025-05-06 19:24:39.774

INFO

[Database] Initializing db at "/config/absdatabase.sqlite"

2025-05-06 19:24:39.834

INFO

[Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so

2025-05-06 19:24:39.836

INFO

[Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so

2025-05-06 19:24:39.836

INFO

[Database] Db supports unaccent and unicode foldings

2025-05-06 19:24:39.836

INFO

[Database] Db connection was successful

2025-05-06 19:24:39.844

INFO

[MigrationManager] Database is already up to date.

2025-05-06 19:24:39.981

INFO

[Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpisode, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackSession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare

2025-05-06 19:24:40.037

INFO

[Database] running ANALYZE

2025-05-06 19:24:40.152

INFO

[Database] ANALYZE completed

2025-05-06 19:24:40.155

INFO

[LogManager] Removed daily log: 2025-04-28.txt

2025-05-06 19:24:40.156

INFO

[LogManager] Removed daily log: 2025-04-29.txt

2025-05-06 19:24:40.156

INFO

[LogManager] Init current daily log filename: 2025-05-06.txt

2025-05-06 19:24:40.252

INFO

[BackupManager] 3 Backups Found

2025-05-06 19:24:40.274

INFO

Listening on port :80

2025-05-06 20:13:22.757

INFO

=== Starting Server ===

2025-05-06 20:13:22.758

INFO

[Server] Init v2.21.0

2025-05-06 20:13:22.758

INFO

[Server] Node.js Version: v20.19.1

2025-05-06 20:13:22.758

INFO

[Server] Platform: linux

2025-05-06 20:13:22.758

INFO

[Server] Arch: x64

2025-05-06 20:13:22.767

INFO

[Database] Initializing db at "/config/absdatabase.sqlite"

2025-05-06 20:13:22.811

INFO

[Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so

2025-05-06 20:13:22.811

INFO

[Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so

2025-05-06 20:13:22.812

INFO

[Database] Db supports unaccent and unicode foldings

2025-05-06 20:13:22.812

INFO

[Database] Db connection was successful

2025-05-06 20:13:22.817

INFO

[MigrationManager] Database is already up to date.

2025-05-06 20:13:22.953

INFO

[Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpisode, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackSession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare

2025-05-06 20:13:22.986

INFO

[Database] running ANALYZE

2025-05-06 20:13:23.132

INFO

[Database] ANALYZE completed

2025-05-06 20:13:23.133

INFO

[LogManager] Init current daily log filename: 2025-05-06.txt

2025-05-06 20:13:23.159

INFO

[BackupManager] 3 Backups Found

2025-05-06 20:13:23.183

INFO

Listening on port :80

2025-05-06 20:13:28.200

INFO

[SocketAuthority] Socket Connected to /audiobookshelf/socket.io MDWLVEGpdY0O8eFIAAAB

2025-05-06 20:18:40.637

INFO

[SocketAuthority] Socket MDWLVEGpdY0O8eFIAAAB disconnected from client "nc543" after 312436ms (Reason: transport close)

2025-05-06 21:22:06.063

INFO

[SocketAuthority] Socket Connected to /audiobookshelf/socket.io LYcqKNzsOdZJFRhLAAAD

2025-05-06 21:48:16.978

INFO

[SocketAuthority] Socket LYcqKNzsOdZJFRhLAAAD disconnected from client "nc543" after 1570915ms (Reason: transport close)

2025-05-06 21:50:03.029

INFO

[SocketAuthority] Socket Connected to /audiobookshelf/socket.io RGdh2Lm_jG49KhgVAAAF

2025-05-06 21:50:04.013

INFO

[SocketAuthority] Socket RGdh2Lm_jG49KhgVAAAF disconnected from client "nc543" after 984ms (Reason: transport close)

2025-05-06 21:50:07.938

INFO

[Auth] User "nc543" logged in from ip ::ffff:172.19.0.1

2025-05-06 21:50:43.263

INFO

[SocketAuthority] Socket Connected to /socket.io XvBvIzsVywmNX9VuAAAH

2025-05-06 21:50:46.842

INFO

[SocketAuthority] Socket XvBvIzsVywmNX9VuAAAH disconnected from client "nc543" after 3579ms (Reason: client namespace disconnect)

2025-05-06 21:50:48.450

INFO

Received ping

2025-05-06 21:50:49.123

INFO

[SocketAuthority] Socket Connected to /socket.io FdNQdonvuklNIz2zAAAJ

2025-05-06 21:50:52.274

INFO

[SocketAuthority] Socket FdNQdonvuklNIz2zAAAJ disconnected from client "nc543" after 3151ms (Reason: client namespace disconnect)

2025-05-06 21:51:25.503

INFO

[Auth] User "nc543" logged in from ip ::ffff:172.19.0.1

2025-05-06 21:55:09.784

INFO

[SocketAuthority] Socket Connected to /audiobookshelf/socket.io z160vgo5iPAZfDlBAAAL

2025-05-06 21:55:11.017

INFO

[SocketAuthority] Socket z160vgo5iPAZfDlBAAAL disconnected from client "nc543" after 1233ms (Reason: transport close)

Additional Notes

It appeared when using the brave browser and the android app. I have not tested on anything else.
Logs were from me poking around in the settings on my desktop web browser.

Originally created by @nc5432 on GitHub (May 7, 2025). ### What happened? I recently set up a reverse proxy to get https working. I am using nginx for it. After getting it set up, the web client permanently has a 'Socket unable to connect' message at the bottom of the screen. However, everything works normally and I am able to listen to audio books. I updated the address on the android app, and it too has some issues. It indicates that it is having an issue connecting to the server with the orange cloud icon, and clicking on it reveals the same message as above. However, everything still works fine. Login works, books load, timestamps sync. This only happens when I am using the reverse proxy. ### What did you expect to happen? Audiobookshelf should not display an error when running behind an https reverse proxy ### Steps to reproduce the issue 1. Install nginx. I am not using the docker version, and am running it on linux mint 2. Install audiobookshelf. I am using the docker compose version and running 2.21.0 3. Configure a reverse proxy to point to audiobookshelf. I have tried both of the following code blocks, and each produce the same result: ``` server{ listen 443 ssl; listen [::]:443 ssl; ssl_certificate {PATH_TO_CERT}; ssl_certificate_key {PATH_TO_KEY}; server_name url.domain.com; location / { proxy_pass http://localhost:13378; } } ``` ``` server{ listen 443 ssl; listen [::]:443 ssl; ssl_certificate {PATH_TO_CERT}; ssl_certificate_key {PATH_TO_KEY}; server_name url.domain.com; location / { proxy_pass http://localhost:13378; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` 4. Connect to the audiobookshelf server through the reverse proxy. ### Audiobookshelf version 2.21.0 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Other (list in "Additional Notes" box) ### Logs ```shell 2025-05-06 19:24:39.765 INFO === Starting Server === 2025-05-06 19:24:39.765 INFO [Server] Init v2.21.0 2025-05-06 19:24:39.765 INFO [Server] Node.js Version: v20.19.1 2025-05-06 19:24:39.765 INFO [Server] Platform: linux 2025-05-06 19:24:39.766 INFO [Server] Arch: x64 2025-05-06 19:24:39.774 INFO [Database] Initializing db at "/config/absdatabase.sqlite" 2025-05-06 19:24:39.834 INFO [Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so 2025-05-06 19:24:39.836 INFO [Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so 2025-05-06 19:24:39.836 INFO [Database] Db supports unaccent and unicode foldings 2025-05-06 19:24:39.836 INFO [Database] Db connection was successful 2025-05-06 19:24:39.844 INFO [MigrationManager] Database is already up to date. 2025-05-06 19:24:39.981 INFO [Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpisode, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackSession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare 2025-05-06 19:24:40.037 INFO [Database] running ANALYZE 2025-05-06 19:24:40.152 INFO [Database] ANALYZE completed 2025-05-06 19:24:40.155 INFO [LogManager] Removed daily log: 2025-04-28.txt 2025-05-06 19:24:40.156 INFO [LogManager] Removed daily log: 2025-04-29.txt 2025-05-06 19:24:40.156 INFO [LogManager] Init current daily log filename: 2025-05-06.txt 2025-05-06 19:24:40.252 INFO [BackupManager] 3 Backups Found 2025-05-06 19:24:40.274 INFO Listening on port :80 2025-05-06 20:13:22.757 INFO === Starting Server === 2025-05-06 20:13:22.758 INFO [Server] Init v2.21.0 2025-05-06 20:13:22.758 INFO [Server] Node.js Version: v20.19.1 2025-05-06 20:13:22.758 INFO [Server] Platform: linux 2025-05-06 20:13:22.758 INFO [Server] Arch: x64 2025-05-06 20:13:22.767 INFO [Database] Initializing db at "/config/absdatabase.sqlite" 2025-05-06 20:13:22.811 INFO [Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so 2025-05-06 20:13:22.811 INFO [Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so 2025-05-06 20:13:22.812 INFO [Database] Db supports unaccent and unicode foldings 2025-05-06 20:13:22.812 INFO [Database] Db connection was successful 2025-05-06 20:13:22.817 INFO [MigrationManager] Database is already up to date. 2025-05-06 20:13:22.953 INFO [Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpisode, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackSession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare 2025-05-06 20:13:22.986 INFO [Database] running ANALYZE 2025-05-06 20:13:23.132 INFO [Database] ANALYZE completed 2025-05-06 20:13:23.133 INFO [LogManager] Init current daily log filename: 2025-05-06.txt 2025-05-06 20:13:23.159 INFO [BackupManager] 3 Backups Found 2025-05-06 20:13:23.183 INFO Listening on port :80 2025-05-06 20:13:28.200 INFO [SocketAuthority] Socket Connected to /audiobookshelf/socket.io MDWLVEGpdY0O8eFIAAAB 2025-05-06 20:18:40.637 INFO [SocketAuthority] Socket MDWLVEGpdY0O8eFIAAAB disconnected from client "nc543" after 312436ms (Reason: transport close) 2025-05-06 21:22:06.063 INFO [SocketAuthority] Socket Connected to /audiobookshelf/socket.io LYcqKNzsOdZJFRhLAAAD 2025-05-06 21:48:16.978 INFO [SocketAuthority] Socket LYcqKNzsOdZJFRhLAAAD disconnected from client "nc543" after 1570915ms (Reason: transport close) 2025-05-06 21:50:03.029 INFO [SocketAuthority] Socket Connected to /audiobookshelf/socket.io RGdh2Lm_jG49KhgVAAAF 2025-05-06 21:50:04.013 INFO [SocketAuthority] Socket RGdh2Lm_jG49KhgVAAAF disconnected from client "nc543" after 984ms (Reason: transport close) 2025-05-06 21:50:07.938 INFO [Auth] User "nc543" logged in from ip ::ffff:172.19.0.1 2025-05-06 21:50:43.263 INFO [SocketAuthority] Socket Connected to /socket.io XvBvIzsVywmNX9VuAAAH 2025-05-06 21:50:46.842 INFO [SocketAuthority] Socket XvBvIzsVywmNX9VuAAAH disconnected from client "nc543" after 3579ms (Reason: client namespace disconnect) 2025-05-06 21:50:48.450 INFO Received ping 2025-05-06 21:50:49.123 INFO [SocketAuthority] Socket Connected to /socket.io FdNQdonvuklNIz2zAAAJ 2025-05-06 21:50:52.274 INFO [SocketAuthority] Socket FdNQdonvuklNIz2zAAAJ disconnected from client "nc543" after 3151ms (Reason: client namespace disconnect) 2025-05-06 21:51:25.503 INFO [Auth] User "nc543" logged in from ip ::ffff:172.19.0.1 2025-05-06 21:55:09.784 INFO [SocketAuthority] Socket Connected to /audiobookshelf/socket.io z160vgo5iPAZfDlBAAAL 2025-05-06 21:55:11.017 INFO [SocketAuthority] Socket z160vgo5iPAZfDlBAAAL disconnected from client "nc543" after 1233ms (Reason: transport close) ``` ### Additional Notes It appeared when using the brave browser and the android app. I have not tested on anything else. Logs were from me poking around in the settings on my desktop web browser.
adam added the bug label 2026-04-25 00:10:13 +02:00
adam closed this issue 2026-04-25 00:10:13 +02:00
Author
Owner

@nichwall commented on GitHub (May 7, 2025):

You have not configured nginx for websockets.
https://nginx.org/en/docs/http/websocket.html

You can also see an example in the project readme.

@nichwall commented on GitHub (May 7, 2025): You have not configured nginx for websockets. https://nginx.org/en/docs/http/websocket.html You can also see an example in the project readme.
Author
Owner

@nc5432 commented on GitHub (May 7, 2025):

It appears that I managed to miss the obvious. Closing this since it's an issue with my reading ability, not the app.

@nc5432 commented on GitHub (May 7, 2025): It appears that I managed to miss the obvious. Closing this since it's an issue with my reading ability, not the app.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2752