[Bug]: Top download button only leading to 502 Bad Gateway #1449

Closed
opened 2026-04-24 23:45:52 +02:00 by adam · 5 comments
Owner

Originally created by @connwork on GitHub (Oct 9, 2023).

Describe the issue

The download button at the top of each audiobook shows 502 bad gateway when clicked.

image

image

docker compose:

version: "3.7"

services:
audiobookshelf:
image: ghcr.io/advplyr/audiobookshelf
container_name: audiobookshelf
environment:
- PUID=1000
- PGID=1000
- TZ=America/Boise
ports:
- 13378:80
volumes:
- /xx/Audio Books:/audiobooks
- /xx/metadata:/metadata
- /xx/audiobookshelf:/config
restart: unless-stopped

Nginx config:

server
{
server_name audible.xxxx.us;

    access_log /var/log/nginx/audiobookshelf.access.log;
    error_log /var/log/nginx/audiobookshelf.error.log;

    add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";

    location / {
                 proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
                 proxy_set_header  X-Forwarded-Proto $scheme;
                 proxy_set_header  Host              $host;
                 proxy_set_header Upgrade            $http_upgrade;
                 proxy_set_header Connection         "upgrade";

                 proxy_http_version                  1.1;

                 proxy_pass                          http://xxxx:xxxx;
                 proxy_redirect                      http:// https://;
               }


listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/xxxx/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xxxx/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server
{
if ($host = audible.xxxx.us) {
return 301 https://$host$request_uri;
} # managed by Certbot

    listen 80;
    server_name audible.xxxx.us;
return 404; # managed by Certbot

}

Steps to reproduce the issue

  1. Install audiobookshelf with provided docker compose (with your own volumes) and nginx configuration (using letsencrypt for certs)
  2. upload a book.
  3. Click the download button

Audiobookshelf version

v2.4.4

How are you running audiobookshelf?

Docker

Originally created by @connwork on GitHub (Oct 9, 2023). ### Describe the issue The download button at the top of each audiobook shows 502 bad gateway when clicked. ![image](https://github.com/advplyr/audiobookshelf/assets/77240181/a295c20a-988d-424b-94e8-f037e93003ff) ![image](https://github.com/advplyr/audiobookshelf/assets/77240181/f318536c-f78f-4171-a58a-a05582470577) docker compose: version: "3.7" services: audiobookshelf: image: ghcr.io/advplyr/audiobookshelf container_name: audiobookshelf environment: - PUID=1000 - PGID=1000 - TZ=America/Boise ports: - 13378:80 volumes: - /xx/Audio Books:/audiobooks - /xx/metadata:/metadata - /xx/audiobookshelf:/config restart: unless-stopped Nginx config: server { server_name audible.xxxx.us; access_log /var/log/nginx/audiobookshelf.access.log; error_log /var/log/nginx/audiobookshelf.error.log; add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive"; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_http_version 1.1; proxy_pass http://xxxx:xxxx; proxy_redirect http:// https://; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/xxxx/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/xxxx/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = audible.xxxx.us) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name audible.xxxx.us; return 404; # managed by Certbot } ### Steps to reproduce the issue 1. Install audiobookshelf with provided docker compose (with your own volumes) and nginx configuration (using letsencrypt for certs) 2. upload a book. 3. Click the download button ### Audiobookshelf version v2.4.4 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:45:52 +02:00
adam closed this issue 2026-04-24 23:45:52 +02:00
Author
Owner

@advplyr commented on GitHub (Oct 9, 2023):

Can you check the server logs to see if the request is reaching the server?

The 502 is coming from nginx and not Abs

@advplyr commented on GitHub (Oct 9, 2023): Can you check the server logs to see if the request is reaching the server? The 502 is coming from nginx and not Abs
Author
Owner

@connwork commented on GitHub (Oct 10, 2023):

Logs:
Top button

INFO: [LibraryItemController] User "XXX" requested download for item "Grit The Power of Passion and Perseverance" at "/audiobooks/Grit The Power of Passion and Perseverance.mp3"

ERROR: [DownloadManager] Archiver error: ENOTDIR: not a directory, scandir '/audiobooks/Grit The Power of Passion and Perseverance.mp3' (zipHelpers.js:41)

node:internal/process/promises:279

            triggerUncaughtException(err, true /* fromPromise */);

            ^

[Error: ENOTDIR: not a directory, scandir '/audiobooks/Grit The Power of Passion and Perseverance.mp3'] {

  errno: -20,

  code: 'ENOTDIR',

  syscall: 'scandir',

  path: '/audiobooks/Grit The Power of Passion and Perseverance.mp3'

}

other buttons
INFO: [LibraryItemController] User "XXX" requested file download at "/audiobooks/Grit The Power of Passion and Perseverance.mp3"

without other code and with successful download.

The 502 is coming from nginx and not Abs

Well... yes. the error is coming from nginx, but the real issue is that somehow these links are doing different things. Maybe it's the backend zip utility that is supposed to zip up multiple files? Is there something that would break this?

@connwork commented on GitHub (Oct 10, 2023): Logs: Top button ``` INFO: [LibraryItemController] User "XXX" requested download for item "Grit The Power of Passion and Perseverance" at "/audiobooks/Grit The Power of Passion and Perseverance.mp3" ERROR: [DownloadManager] Archiver error: ENOTDIR: not a directory, scandir '/audiobooks/Grit The Power of Passion and Perseverance.mp3' (zipHelpers.js:41) node:internal/process/promises:279 triggerUncaughtException(err, true /* fromPromise */); ^ [Error: ENOTDIR: not a directory, scandir '/audiobooks/Grit The Power of Passion and Perseverance.mp3'] { errno: -20, code: 'ENOTDIR', syscall: 'scandir', path: '/audiobooks/Grit The Power of Passion and Perseverance.mp3' } ``` other buttons `INFO: [LibraryItemController] User "XXX" requested file download at "/audiobooks/Grit The Power of Passion and Perseverance.mp3"` without other code and with successful download. > The 502 is coming from nginx and not Abs Well... yes. the error is coming from nginx, but the real issue is that somehow these links are doing different things. Maybe it's the backend zip utility that is supposed to zip up multiple files? Is there something that would break this?
Author
Owner

@advplyr commented on GitHub (Oct 10, 2023):

I just reproduced this. It has to do with the library item being a file in the root directory instead of a dir

@advplyr commented on GitHub (Oct 10, 2023): I just reproduced this. It has to do with the library item being a file in the root directory instead of a dir
Author
Owner

@connwork commented on GitHub (Oct 10, 2023):

I just reproduced this. It has to do with the library item being a file in the root directory instead of a dir

A great workaround will be to put everything in a folder. Thank you! However, it may be a good idea to push a fix for this given that audiobookshelf does import books from the root folder automatically.

@connwork commented on GitHub (Oct 10, 2023): > I just reproduced this. It has to do with the library item being a file in the root directory instead of a dir A great workaround will be to put everything in a folder. Thank you! However, it may be a good idea to push a fix for this given that audiobookshelf does import books from the root folder automatically.
Author
Owner

@advplyr commented on GitHub (Oct 29, 2023):

Fixed in v2.5.0

@advplyr commented on GitHub (Oct 29, 2023): Fixed in [v2.5.0](https://github.com/advplyr/audiobookshelf/releases/tag/v2.5.0)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1449