If you are facing with 502 bad gateway error on magento admin page, and you are using nginx and php-fpm, you can try below solution

open php.ini file with text editor and find

output_buffering = 4096

replace with

output_buffering = 65535

After that restart your nginx and php-fpm services