Hi,
As you siad you get a 502 gateway error, if your notebook is stored on OneDrive, check Microsoft Service Health status page for any outages.
Are you using any proxy and VPN?
If the Microsoft Service is OK, you do not connect any proxy or VPN, please delete the OneNote cache files to check this issue.
- Please make sure your notebooks are all already synced successfully first. Otherwise, before doing following steps, for notebooks that aren't fully synced across all your devices, make sure you copy and back up any unsynced recent notes on the originating PC or device.)
- Close OneNote, go to File > Options > Save & Backup > Scroll down, check the "Cach File Location".
- Locate to the path that you find, open "16.0" folder, open "cache" folder, and empty this folder.
If this step does not work, I also suggest you copy all sections to a new one. (Please make sure your notebooks are all already synced successfully first.)
- Export the Notebooks as .onepkg format files to local computer, we may call it "Backup".

- Open the local Backup.onepkg in OneNote, close the previous one.
- Then go to the notebook online storage, such as OneDrive, create a new notebook, we may call it "New".
- Find Backup notebook in OneNote, right - click one each section tab, click "Move or Copy".

- Copy each section to the "New".
- After all the sections have been copied to the "New" notebook, close the "Backup". Then check the sync issues.
If nothing helps, have you tried reinstalling the OneNote or Office suite before?
If re-installing Office does not work, I suggest you open a ticket like Emi suggested.
The references you may have a look:
Fix issues when you can't sync OneNote
OneNote syncing best practices
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.