[Bug]: systemd service won't start #783

Closed
opened 2026-04-24 23:21:30 +02:00 by adam · 18 comments
Owner

Originally created by @bipox on GitHub (Nov 26, 2022).

Describe the issue

Hi,

First of all, thank you very much for this amazing piece of software!

Bug: it used to work, I don't know exactly when the issue started. The systemd service fails to start Audiobookshelf.
I tried a clean install, same.

sudo journalctl -ln 2000 -u audiobookshelf.service
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at JSON.parse (<anonymous>)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at new Database (/snapshot/audiobookshelf/server/libs/njodb/index.js)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at new Db (/snapshot/audiobookshelf/server/Db.js:28:27)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at new Server (/snapshot/audiobookshelf/server/Server.js)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Object.<anonymous> (/snapshot/audiobookshelf/prod.js)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Module._compile (pkg/prelude/bootstrap.js:1887:22)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Module.load (node:internal/modules/cjs/loader:981:32)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]:     at Function.runMain (pkg/prelude/bootstrap.js:1940:12)
nov. 18 02:35:24 hpserver-ubuntu systemd[1]: audiobookshelf.service: Main process exited, code=exited, status=7/NOTRUNNING
nov. 18 02:35:24 hpserver-ubuntu systemd[1]: audiobookshelf.service: Failed with result 'exit-code'.
nov. 18 02:35:25 hpserver-ubuntu systemd[1]: audiobookshelf.service: Scheduled restart job, restart counter is at 11.
nov. 18 02:35:25 hpserver-ubuntu systemd[1]: Stopped Self-hosted audiobook server for managing and playing audiobooks.
nov. 18 02:35:25 hpserver-ubuntu systemd[1]: Started Self-hosted audiobook server for managing and playing audiobooks.
nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: production Config /usr/share/audiobookshelf/config /usr/share/audiobookshelf/metadata
nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: undefined:1
nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: SyntaxError: Unexpected end of JSON input

Steps to reproduce the issue

  1. add PPA, install audiobookshelf
  2. audiobookshelf.service fails

Audiobookshelf version

v2.2.5

How are you running audiobookshelf?

Debian/PPA

Originally created by @bipox on GitHub (Nov 26, 2022). ### Describe the issue Hi, First of all, thank you very much for this amazing piece of software! Bug: it used to work, I don't know exactly when the issue started. The systemd service fails to start Audiobookshelf. I tried a clean install, same. ``` sudo journalctl -ln 2000 -u audiobookshelf.service nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at JSON.parse (<anonymous>) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at new Database (/snapshot/audiobookshelf/server/libs/njodb/index.js) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at new Db (/snapshot/audiobookshelf/server/Db.js:28:27) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at new Server (/snapshot/audiobookshelf/server/Server.js) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Object.<anonymous> (/snapshot/audiobookshelf/prod.js) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Module._compile (pkg/prelude/bootstrap.js:1887:22) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Module.load (node:internal/modules/cjs/loader:981:32) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) nov. 18 02:35:24 hpserver-ubuntu audiobookshelf[3262]: at Function.runMain (pkg/prelude/bootstrap.js:1940:12) nov. 18 02:35:24 hpserver-ubuntu systemd[1]: audiobookshelf.service: Main process exited, code=exited, status=7/NOTRUNNING nov. 18 02:35:24 hpserver-ubuntu systemd[1]: audiobookshelf.service: Failed with result 'exit-code'. nov. 18 02:35:25 hpserver-ubuntu systemd[1]: audiobookshelf.service: Scheduled restart job, restart counter is at 11. nov. 18 02:35:25 hpserver-ubuntu systemd[1]: Stopped Self-hosted audiobook server for managing and playing audiobooks. nov. 18 02:35:25 hpserver-ubuntu systemd[1]: Started Self-hosted audiobook server for managing and playing audiobooks. nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: production Config /usr/share/audiobookshelf/config /usr/share/audiobookshelf/metadata nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: undefined:1 nov. 18 02:35:26 hpserver-ubuntu audiobookshelf[3360]: SyntaxError: Unexpected end of JSON input ``` ### Steps to reproduce the issue 1. add PPA, install audiobookshelf 2. audiobookshelf.service fails ### Audiobookshelf version v2.2.5 ### How are you running audiobookshelf? Debian/PPA
adam added the bug label 2026-04-24 23:21:30 +02:00
adam closed this issue 2026-04-24 23:21:31 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

Did you edit any of the JSON files in your /config?
The default path for the db json files is /usr/share/audiobookshelf/config.

Inside there you will see a folder for each db entity.
Inside each of those folders you will find a folder named data that contains multiple JSON files.

Those files are not actually valid JSON but instead they contain a valid JSON object on each line. The error is indicating that in the /usr/share/audiobookshelf/config/libraryItems/data folder there is a .json file that has a line with invalid JSON.

I don't believe any recent update would have caused this because we would have already had many reports of the release not working. I'm not sure how one of those .json files could have been changed without manually going in and changing it.

@advplyr commented on GitHub (Nov 26, 2022): Did you edit any of the JSON files in your `/config`? The default path for the db json files is `/usr/share/audiobookshelf/config`. Inside there you will see a folder for each db entity. Inside each of those folders you will find a folder named `data` that contains multiple JSON files. Those files are not actually valid JSON but instead they contain a valid JSON object on each line. The error is indicating that in the `/usr/share/audiobookshelf/config/libraryItems/data` folder there is a `.json` file that has a line with invalid JSON. I don't believe any recent update would have caused this because we would have already had many reports of the release not working. I'm not sure how one of those `.json` files could have been changed without manually going in and changing it.
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

Everything is out of the box, I don't remember changing anything.

@bipox commented on GitHub (Nov 26, 2022): Everything is out of the box, I don't remember changing anything.
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

Before updating to v2.2.5 what was the version you had before?

Unfortunately I think this will require deleting the db. You could go line by line in the .json file and find the invalid JSON object or if you have a backup you could try applying a backup. A backup replaces the DB with an older copy.

@advplyr commented on GitHub (Nov 26, 2022): Before updating to v2.2.5 what was the version you had before? Unfortunately I think this will require deleting the db. You could go line by line in the `.json` file and find the invalid JSON object or if you have a backup you could try applying a backup. A backup replaces the DB with an older copy.
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

In /etc/default I have a file named audiobookshelf, but no directory audiobookshelf.

I believe I was on version 2.2.4 before

edit: what I did step by step (I'm not sure what matters so maybe this will help)

  1. added PPA and installed audiobookshelf. It worked (did I say this is a brilliant program already?). I can't remember what the first version was I installed. Maybe I can look it up?
  2. today no audiobookshelf. I checked the .service, and saw this error.
  3. I upgraded audiobookshelf from 2.2.4 to 2.2.5
  4. same error
  5. I did a sudo apt purge audiobookshelf and sudo rm -r /usr/share/audiobookshelf/ (because it said directory wasn't empty and couldn't get deleted). I didn't bother with backing up, I simply noted the time of the two books I'm reading.
  6. rebooted
  7. reinstalled audiobookshelf
  8. same error
@bipox commented on GitHub (Nov 26, 2022): In /etc/default I have a file named audiobookshelf, but no directory audiobookshelf. I believe I was on version 2.2.4 before edit: what I did step by step (I'm not sure what matters so maybe this will help) 1. added PPA and installed audiobookshelf. It worked (did I say this is a brilliant program already?). I can't remember what the first version was I installed. Maybe I can look it up? 2. today no audiobookshelf. I checked the .service, and saw this error. 3. I upgraded audiobookshelf from 2.2.4 to 2.2.5 4. same error 5. I did a `sudo apt purge audiobookshelf` and `sudo rm -r /usr/share/audiobookshelf/` (because it said directory wasn't empty and couldn't get deleted). I didn't bother with backing up, I simply noted the time of the two books I'm reading. 6. rebooted 7. reinstalled audiobookshelf 8. same error
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

Oh I put the wrong path. /usr/share/audiobookshelf/config
I'll update my prev answers to not confuse someone else who stumbles on this

@advplyr commented on GitHub (Nov 26, 2022): Oh I put the wrong path. `/usr/share/audiobookshelf/config` I'll update my prev answers to not confuse someone else who stumbles on this
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

Oh you already deleted the db if you did sudo rm -r /usr/share/audiobookshelf/.
When updating versions that's not something you want to delete

Check what is in there now

@advplyr commented on GitHub (Nov 26, 2022): Oh you already deleted the db if you did `sudo rm -r /usr/share/audiobookshelf`/. When updating versions that's not something you want to delete Check what is in there now
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

I only deleted the directory when I decided to do a clean install.

Now /usr/share/audiobookshelf only has a file named audiobookshelf, no config directory

@bipox commented on GitHub (Nov 26, 2022): I only deleted the directory when I decided to do a clean install. Now `/usr/share/audiobookshelf` only has a file named `audiobookshelf`, no `config` directory
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

What is the contents of that file?

Something seems to have changed from the default config file. The config file is the file here /etc/default/audiobookshelf by default and contains the paths to where the db should be

@advplyr commented on GitHub (Nov 26, 2022): What is the contents of that file? Something seems to have changed from the default config file. The config file is the file here `/etc/default/audiobookshelf` by default and contains the paths to where the db should be
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

cat /etc/default/audiobookshelf
METADATA_PATH=/usr/share/audiobookshelf/metadata
CONFIG_PATH=/usr/share/audiobookshelf/config
FFMPEG_PATH=/usr/lib/audiobookshelf-ffmpeg/ffmpeg
FFPROBE_PATH=/usr/lib/audiobookshelf-ffmpeg/ffprobe
TONE_PATH=/usr/lib/audiobookshelf-ffmpeg/tone
PORT=13378
HOST=0.0.0.0

/usr/share/audiobookshelf/audiobookshelf is the binary I guess. I can start it and it opens on port 3333. And it works, but when starting it again nothing has been saved

@bipox commented on GitHub (Nov 26, 2022): ``` cat /etc/default/audiobookshelf METADATA_PATH=/usr/share/audiobookshelf/metadata CONFIG_PATH=/usr/share/audiobookshelf/config FFMPEG_PATH=/usr/lib/audiobookshelf-ffmpeg/ffmpeg FFPROBE_PATH=/usr/lib/audiobookshelf-ffmpeg/ffprobe TONE_PATH=/usr/lib/audiobookshelf-ffmpeg/tone PORT=13378 HOST=0.0.0.0 ``` `/usr/share/audiobookshelf/audiobookshelf` is the binary I guess. I can start it and it opens on port 3333. And it works, but when starting it again nothing has been saved
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

If this directory /usr/share/audiobookshelf does not exist as you said then it would not work at all.

This is where all data from abs will be stored. If it is creating it new every time you start the server then something might be off with the permissions

@advplyr commented on GitHub (Nov 26, 2022): If this directory `/usr/share/audiobookshelf` does not exist as you said then it would not work at all. This is where all data from abs will be stored. If it is creating it new every time you start the server then something might be off with the permissions
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

So in /lib/systemd/system/audiobookshelf.service I commented out

User=audiobookshelf
Group=audiobookshelf

and now it works! It also start on port 13378

Do you know why that is and is it safe to keep this change?

@bipox commented on GitHub (Nov 26, 2022): So in `/lib/systemd/system/audiobookshelf.service` I commented out ``` User=audiobookshelf Group=audiobookshelf ``` and now it works! It also start on port 13378 Do you know why that is and is it safe to keep this change?
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

A user and group named audiobookshelf gets created when installing. I believe there is a github request open to allow changing that but I'm not sure yet.
The audiobookshelf user/group did not have permissions to access the db files I'm guessing.
You may need to comment that out every time you do an update if you want to go that route. Otherwise you can give the audiobookshelf user/group permissions to the folders it uses.

@advplyr commented on GitHub (Nov 26, 2022): A user and group named audiobookshelf gets created when installing. I believe there is a github request open to allow changing that but I'm not sure yet. The audiobookshelf user/group did not have permissions to access the db files I'm guessing. You may need to comment that out every time you do an update if you want to go that route. Otherwise you can give the audiobookshelf user/group permissions to the folders it uses.
Author
Owner

@bipox commented on GitHub (Nov 26, 2022):

Just to be clear: I did not modify any ownership or permissions on any directory, nor did I change users or groups

@bipox commented on GitHub (Nov 26, 2022): Just to be clear: I did not modify any ownership or permissions on any directory, nor did I change users or groups
Author
Owner

@advplyr commented on GitHub (Nov 26, 2022):

Not sure. I'll keep an eye out for other users having an issue like this.

There has been no recent update that altered the debian package.

@advplyr commented on GitHub (Nov 26, 2022): Not sure. I'll keep an eye out for other users having an issue like this. There has been no recent update that altered the debian package.
Author
Owner

@moozhub commented on GitHub (May 18, 2023):

@advplyr I seem to be having the same exact issue, and can't really put my thumb on what it is.. I tried reverting the installation I have back to a previous backup that was made and even that didn't correct the problem ... do you have any suggestions on what I should try to get this back up and running?

I really have no idea what the problem could be, it almost seems like I updated and it ran into this problem. I made sure that the installation directory is that of the user defined in the systemd unit file, which happens to be audiobookshelf. I also tried poking around some of the JSON files but haven't really been able to find anything that pokes out as being a invalid JSON file of some sort.. it'd be great if the output would spit out which file it's complaining about

May 17 18:42:31 server-example audiobookshelf[442176]: undefined:1
May 17 18:42:31 server-example audiobookshelf[442176]: SyntaxError: Unexpected end of JSON input
May 17 18:42:31 server-example audiobookshelf[442176]:     at JSON.parse (<anonymous>)
May 17 18:42:31 server-example audiobookshelf[442176]:     at new Database (/snapshot/audiobookshelf/server/libs/njodb/index.js)
May 17 18:42:31 server-example audiobookshelf[442176]:     at new Db (/snapshot/audiobookshelf/server/Db.js:30:27)
May 17 18:42:31 server-example audiobookshelf[442176]:     at new Server (/snapshot/audiobookshelf/server/Server.js)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Object.<anonymous> (/snapshot/audiobookshelf/prod.js)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Module._compile (pkg/prelude/bootstrap.js:1887:22)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Module.load (node:internal/modules/cjs/loader:981:32)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
May 17 18:42:31 server-example audiobookshelf[442176]:     at Function.runMain (pkg/prelude/bootstrap.js:1940:12)
May 17 18:42:31 server-example systemd[1]: audiobookshelf.service: Main process exited, code=exited, status=7/NOTRUNNING
@moozhub commented on GitHub (May 18, 2023): @advplyr I seem to be having the same exact issue, and can't really put my thumb on what it is.. I tried reverting the installation I have back to a previous backup that was made and even that didn't correct the problem ... do you have any suggestions on what I should try to get this back up and running? I really have no idea what the problem could be, it almost seems like I updated and it ran into this problem. I made sure that the installation directory is that of the user defined in the systemd unit file, which happens to be audiobookshelf. I also tried poking around some of the JSON files but haven't really been able to find anything that pokes out as being a invalid JSON file of some sort.. it'd be great if the output would spit out which file it's complaining about ```May 17 18:42:31 server-example audiobookshelf[442176]: production Config /usr/share/audiobookshelf/config /usr/share/audiobookshelf/metadata May 17 18:42:31 server-example audiobookshelf[442176]: undefined:1 May 17 18:42:31 server-example audiobookshelf[442176]: SyntaxError: Unexpected end of JSON input May 17 18:42:31 server-example audiobookshelf[442176]: at JSON.parse (<anonymous>) May 17 18:42:31 server-example audiobookshelf[442176]: at new Database (/snapshot/audiobookshelf/server/libs/njodb/index.js) May 17 18:42:31 server-example audiobookshelf[442176]: at new Db (/snapshot/audiobookshelf/server/Db.js:30:27) May 17 18:42:31 server-example audiobookshelf[442176]: at new Server (/snapshot/audiobookshelf/server/Server.js) May 17 18:42:31 server-example audiobookshelf[442176]: at Object.<anonymous> (/snapshot/audiobookshelf/prod.js) May 17 18:42:31 server-example audiobookshelf[442176]: at Module._compile (pkg/prelude/bootstrap.js:1887:22) May 17 18:42:31 server-example audiobookshelf[442176]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) May 17 18:42:31 server-example audiobookshelf[442176]: at Module.load (node:internal/modules/cjs/loader:981:32) May 17 18:42:31 server-example audiobookshelf[442176]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) May 17 18:42:31 server-example audiobookshelf[442176]: at Function.runMain (pkg/prelude/bootstrap.js:1940:12) May 17 18:42:31 server-example systemd[1]: audiobookshelf.service: Main process exited, code=exited, status=7/NOTRUNNING
Author
Owner

@advplyr commented on GitHub (May 18, 2023):

@moozhub I'm not sure. Maybe try removing the database to start fresh and loading in your backup after you confirm it works.

@advplyr commented on GitHub (May 18, 2023): @moozhub I'm not sure. Maybe try removing the database to start fresh and loading in your backup after you confirm it works.
Author
Owner

@moozhub commented on GitHub (May 18, 2023):

@advplyr when you say "remove the database", what do you mean specifically, are you talking about all the JSON files?

@moozhub commented on GitHub (May 18, 2023): @advplyr when you say "remove the database", what do you mean specifically, are you talking about all the JSON files?
Author
Owner

@moozhub commented on GitHub (May 18, 2023):

@advplyr all right ... I found the issue with mine, it turns out the file /usr/share/audiobookshelf/config/libraryItems/njodb.properties was empty for some reason, I restored it using the info from one of the other properties files. Thanks

@moozhub commented on GitHub (May 18, 2023): @advplyr all right ... I found the issue with mine, it turns out the file /usr/share/audiobookshelf/config/libraryItems/njodb.properties was empty for some reason, I restored it using the info from one of the other properties files. Thanks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#783