nginx 502 Bad Gateway

Solution to the nginx 502 Bad Gateway Error Message. mysql-bin files too large. Debugging & fixing the problem in my case.

502 Bad Gateway

nginx 502 Bad Gateway

I have received a 502 Bad Gateway Error from the nginx webserver on all of my websites. First step: figure out what the access.log and error.log file includes.

nginx 502 Bad Gateway 1

Disk space full

The error.log is showing multiple entries, that the disk space is full.

nginx 502 Bad Gateway 2

In my server is a 120GB SSD which is 100% used. With the du -sh command you can list the folders which eat all of the disk space.

nginx 502 Bad Gateway 3

Mysql-bin file size

Directory for directory was inspected and /var/lib/mysql/ was the problem. That directory includes about 100 different mysql-bin files, which are partly 1GB large.

nginx 502 Bad Gateway 4

Solution

After a bit of research what these files are needed for i found that article:

https://www.cyberciti.biz/faq/what-is-mysql-binary-log/

For replication purposes those files are generated. If you have a mysql master server you can mirror that data onto other satellites / nodes. In my case this wasn’t in use. Another purpose is that those files contain backups for data recovery. Because i have different cronjob scripts, which backup my mysql data onto an external drive, this wasn’t needed too.

Therefore i commented the replication feature out.

nginx 502 Bad Gateway 5

The mysql server had an issue to restart, because the disk was full. After the deletion of a couple mysql-bin files it worked perfectly. After that my websites were available again.

nginx 502 Bad Gateway 6

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Scroll to Top