Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Server

Notices

Reply
 
Thread Tools Search this Thread
Old 03-05-2021, 10:02 PM   #1
georgehuang
Enthusiast
georgehuang began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Oct 2020
Device: MacBook, iPhone, Kindle Paperwhite
502 Bad Gateway errors on nginx server

I now have Calibre Content Server running with nginx as a virtual host, which has received a SSL certificate from Certbot for security's sake. They all run on Ubuntu 20.04 on a VPS. And I also set up a startup service that runs Calibre:

Code:
/opt/calibre/calibre-server /home/ubuntu/Calibre --enable-local-write --enable-auth --auth-mode "basic" --ban-after 5 --ban-for 5 --log /home/ubuntu/log/calibre.log
Most of the time Calibre runs great, but I get 502 Bad Gateway error about twice or thrice a day. I have logs enabled but calibre.log does not show anything related. nginx's error.log do have reports like:

Code:
[error] 641#641: *1773 connect() failed (111: Connection refused) while connecting to upstream ...
This can be easily fixed by restarting Calibre server, without having to restart nginx. However, that means I will have to ssh into my VPS and run the command, which is not as easy to do when I am out with only a mobile phone.

Any idea why this might happen? Is there anything I can do to fix this?
georgehuang is offline   Reply With Quote
Old 03-05-2021, 10:22 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You sure there is nothing in the calibre server logs? Does it happen after doing a particular type of activity?
kovidgoyal is offline   Reply With Quote
Old 03-06-2021, 02:25 AM   #3
georgehuang
Enthusiast
georgehuang began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Oct 2020
Device: MacBook, iPhone, Kindle Paperwhite
Yes, nothing on calibre.log other than the normal:

Code:
calibre server listening on 0.0.0.0:8080
OPDS feeds advertised via BonJour at: ....
Weirdly, 502 Bad Gateway happens quite randomly. Mostly it happens when I am doing nothing at all; went to bed and wake up with 502, for example. Happened twice while I was reading and taking notes, as far as I can remember.
georgehuang is offline   Reply With Quote
Old 03-06-2021, 05:15 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Without anything in the logs I cant really help you. Other than to suggest that you make sure you are running the official calibre binaries and not the distro packaed version of calibre.
kovidgoyal is offline   Reply With Quote
Old 03-06-2021, 08:17 AM   #5
georgehuang
Enthusiast
georgehuang began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Oct 2020
Device: MacBook, iPhone, Kindle Paperwhite
Understood. And yes, I am using the official binaries. Will try to get more info if I can.
georgehuang is offline   Reply With Quote
Old 03-31-2021, 03:21 AM   #6
georgehuang
Enthusiast
georgehuang began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Oct 2020
Device: MacBook, iPhone, Kindle Paperwhite
I think I figured out what went wrong.

So my VPS instance has only 512 MBs of RAM. Although all it does is running Calibre Content Server on nginx, it still runs out of memory through time. And when the memory runs out on a Linux machine, something named Out of Memory (OOM) killer is triggered and kills Calibre, which results in nginx not being able to connect to the backend so finally "502 Bad Gateway".

I added 1GB of swap memory to my instance, and Calibre has not been killed since then.
georgehuang is offline   Reply With Quote
Reply

Tags
calibre, content server, nginx


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any suggestions? Intermittant problems with Content Server/NGINX haertig Calibre 4 02-28-2018 12:50 AM
Calibre device and server errors wn1ytw Devices 9 10-25-2013 08:24 AM
Excited! But errors for headless server. apiontek Devices 3 08-25-2013 04:07 PM
0.9.36 related server errors khahoon Calibre 0 06-26-2013 03:26 PM
Stand alone server - Chrome errors robin58 Calibre 7 02-19-2013 11:29 PM


All times are GMT -4. The time now is 09:43 PM.


MobileRead.com is a privately owned, operated and funded community.