最新バージョンへのアップデート後、502 Bad Gateway

Did you follow the advice in PostgreSQL 15 update? You might also vaccuum the database.