Difference between revisions of "Fix a 502 Bad Gateway error on calibre-web"

From Parallel Library Services
Jump to navigation Jump to search
Line 1: Line 1:
[[File:502_bad_gateway.jpg|thumb]]
[[File:502_bad_gateway.jpg|thumb]]
Sometimes, when making changes to the server settings in the calibre-web browser interface, you may get a 502 error. This means that the server isn't responding to HTTP requests. This quick-fix assumes you have SSH access to the machine you are running calibre-web from. If you have local access, even better, you can just restart the server directly.
Sometimes, when making changes to the server settings in the calibre-web browser interface, you may get a 502 error. This usually can be fixed by checking to see if the web server is running, then if it is, stopping and restarting the script that runs calibre-web.
 
This quick-fix assumes you have SSH access to the machine you are running calibre-web from. If you have local access, even better, you can just restart the server directly.


Connect to the server. In my case, I have the hostname set as ''parallel-library'' in the configuration settings, which is the file that can be found in the location<code>~/.ssh/config</code> in most Unix-like systems:
Connect to the server. In my case, I have the hostname set as ''parallel-library'' in the configuration settings, which is the file that can be found in the location<code>~/.ssh/config</code> in most Unix-like systems:

Revision as of 18:07, 2 November 2021

502 bad gateway.jpg

Sometimes, when making changes to the server settings in the calibre-web browser interface, you may get a 502 error. This usually can be fixed by checking to see if the web server is running, then if it is, stopping and restarting the script that runs calibre-web.

This quick-fix assumes you have SSH access to the machine you are running calibre-web from. If you have local access, even better, you can just restart the server directly.

Connect to the server. In my case, I have the hostname set as parallel-library in the configuration settings, which is the file that can be found in the location~/.ssh/config in most Unix-like systems:

 ssh parallel-library

Activate the python virtual environment

cd parallel_library
source venv/bin/activate

Check to see if nginx is running

systemctl status nginx

Find the process ID (PID) for all Python scripts running:

ps -aux | grep python

For me, this produces:

root     29857  0.3  1.0 297248 83260 ?        Sl   15:09   0:07 python cps.py
root     30054  0.0  0.0   5812   888 pts/0    S+   15:44   0:00 grep python

The process running the script cps.py is the one we want to stop, then restart. Note down the number next to this process, the PID. In this case it is 29857.

Then, kill the process (swap out the PID)

kill -9 29857

Run the python script in the background (you can close the terminal after this)

nohup python cps.py

Refresh the page in your browser (do a hard refresh to clear cache) and see if the page reappears. Do a quick uploading/downloading test to make sure it’s all working ok.