How to setup ebook server (Calibre)

I have a huge problem I had to address long time ago. I have so many books, but my organization is zero. At first, I tried to upload my ebooks to Kindle service, but not all books (larger ones) would fit to the service and after some time, I had a mess on my hands, because books would be across devices and directories.

And who is to blame for this? Humble Bundle. They have all kind of great deals on books and comics. I bought a lot of books there since they started they Book and Comics packs and after some time I figured that I’m getting lost in my collections.

Really great site, if you haven’t checked it out yet, I highly recommend it.

Now, onto our problem… Ebook organization.

I looked a lot and tested a lot of solutions, and in the end I selected to stick with Calibre. I checked Ubooquity and some other solutions, but in the end, I went back to Calibre, because it simply fits best my needs.

Before we begin

I’m doing this on Ubuntu 20.04 with desktop environment. I did it this way because it is easier to organize books on machine with GUI. All of this can be also done on server without GUI, there is still web interface through which you can organize your collections.

My machine also has fixed IP address, and other than that, it is empty machine.

I allocated 2vCPUs, 1GB or RAM and 120GB of hard drive for this machine.

I will be using it on local network and it will be only ebook server, so I don’t need HTTPS or security hardening. So if you are looking for that, you will need to check other sources on the internet.

Installation of Calibre server

First, we need to prepare dependencies

sudo apt update && sudo apt install -y libfontconfig libgl1-mesa-glx

Now we will download and then install Calibre…


I’m doing all of this inside my home folder.

Start installation with

sudo sh

If you are doing this in installation without GUI you will get error regarding desktop environment, but you can safely ignore it.

Creating a library, adding a book.

Since I did this around last Christmas, I think it is appropriate that I download Christmas Carol. We will download the book from Project Gutenberg. Project Gutenberg has free ebooks in public domain. Great resource for many classic books.

Ok, lets download Christmas Carol.

wget -O

I will now create directory named calibre-library. Location of the directory will be in /home/zeljko/ folder. I already mentioned that I will be doing all of this inside my home dir.

mkdir calibre-library

Now, we will add downloaded book to our library with calibredb command.

calibredb add *.mobi --with-library calibre-library/

Ok, I got “Added book ids: 1” message which signal that everything went ok.

Running Calibre Content Server

If you have firewall up and running make sure you let through port 8080

sudo ufw allow 8080

Let’s start Calibre Content Server

calibre-server calibre-library

If you enter your IP address with port 8080 into browser you will be greeted with Calibre library. is the IP address of my ebook server.

Ok, this is the way you will start your Calibre Content Server. But you will have to do it manually every time.

We will now create service for Calibre Content Server

We will create calibre-server.service file inside /etc/systemd/system folder.

sudo nano /etc/systemd/system/calibre-server.service

Enter this into the file. Be sure to exchange zeljko with your user account on ubuntu.

## startup service
Description=calibre content server

ExecStart=/opt/calibre/calibre-server /home/zeljko/calibre-library --enable-local-write


Ok, we will now enable and start the service we created.

sudo systemctl enable calibre-server
sudo systemctl start calibre-server
sudo systemctl status calibre-server

Status says that we did good and service is running.

Reboot your server.

sudo reboot

Adding users to Calibre Content Server

If you try to upload a book through web interface of Calibre Content Server, you will get error “Anonymous users are not allowed to make changes”

Ok. Lets fix this and add a user to our Calibre Content Server.

First, we need to stop Calibre service

sudo systemctl stop calibre-server

We will now start Calibre user management and add a user.

calibre-server --manage-users

You will then be asked what you want to do. We will select 1, define our username and password. This is how a process looks like.

Ok, before starting back again our Calibre Server we need to edit service file we defined earlier.


sudo nano /etc/systemd/system/calibre-server.service

and add


to the end of the line which starts with “ExecStart=”

The line should look like this

ExecStart=/opt/calibre/calibre-server /home/zeljko/calibre-library --enable-local-write --enable-auth

and in the picture…

Reload and start the service

sudo systemctl daemon-reload
sudo systemctl start calibre-server

Now, next time we start Calibre in web browser, pop-up for login should appear.

Now you should be able to add books to your Calibre via web browser.

Automagically adding books to your library

It would be great if we could define one directory to which we could upload books, and then cron job can add them to Calibre.

We will create folder named books-to-add (again, I will do it in my home folder). Right after we create the folder, we will enter it.

mkdir ~/books-to-add
cd ~/books-to-add

Ok, now we will download A Tale of Two Cities by Charles Dickens.

wget -o twocities.epub

Now, we need to open Crontab

crontab -e

I don’t have anything defined, so empty one will be used. I entered 1 since I use nano editor.

In the command, make sure to change zeljko for your username, and instead “yourcalibreuser” enter usarnem you defined for your Calibre server. Also change “YourPassword” for the password you defined for your Calibre user.

*/5 * * * * calibredb add /home/zeljko/books-to-add/ -r --with-library http://localhost:8080#calibre-library --username yourcalibreuser --password YourPassword && rm -r /home/zeljko/books-to-add/*

This job will run every 5 minutes, so check your books-to-add after 5 minutes, it should be empty, and your Calibre library should be richer for one book.

In my books-to-add folder twocities was listed

After five minutes…

Also, in web interface…

Book is added!!


Ok, that is it, we now have ebook server up and running inside local network.

One thing that is crashing on me, is calibre inside GUI in my Ubuntu install, I didn’t have a time to check the errors out, but other than that, everything is fine and working.