502 Proxy error when yum repository sync and content view publishing with same yum repository

Problem:
502 Proxy error when trying to sync a yum repository with Below Upstream URL-

After some retries it gets synced successfully.
When trying to create a content view with the same openstack-train repo that was synced before the same error comes when publishing the content view.After some tries the error gets cleared.
Below is the snap of the error taken from the task section,


The error started to occur for many repos now.
Expected outcome:
Sync of repository and content view publishing without getting the above proxy error.
Foreman and Proxy versions:
Foreman 3.5 and Katello 4.7
Distribution and version:
Rocky Linux release 8.7 (Green Obsidian)