Every Sync Must Be Forced, Normal Sync Results in Error 400

I have had this issue for around a month (started early January 2020 iirc). I’m not sure what triggered it, as all I was doing was syncing normally, then one day it just didn’t work for PC or Android.

I tried finding other posts here and on Reddit about this issue, but only one post offered a solution (set up a new Ankiweb account) which didn’t work for me.

Version: 2.1.24 (same issue when upgrading to 38)

OS: Ubuntu 18.04 (hesitant to upgrade without this issue fixed)

I installed Anki via the commandline – I did not install the 2.1.0 version that Ubuntu offers through the package manager.


Current Issue: Syncing normally on Anki for PC and Ankidroid results in the same message. It will actually sync some data (never the same amount) before displaying the error.

When I first encountered this problem, the error message on PC was slightly different than the error message I get now.

[So at some point, the error message actually changed, and I’m not sure why.]


First Error Message (screenshotted around 28 Jan 2021, on PC): [screenshot here]

A network error occurred.
Error details: HTTP status client error (400 Bad Request) for url ()

On Ankidroid, there was no error message – a blank box would appear with “:”.

As of 31 Jan 2021, a different message appeared:

Second Error Message: [screenshot here]

On Anki for PC, this is the exact message I get:

Syncing failed:
Traceback (most recent call last):
File "aqt/sync.py", line 429, in _sync
File "aqt/sync.py", line 409, in _abortingSync
File "anki/sync.py", line 120, in sync
File "anki/sync.py", line 603, in chunk
File "anki/sync.py", line 619, in _run
File "anki/sync.py", line 546, in req
File "anki/sync.py", line 479, in assertOk
Exception: Unknown response code: 400

On AnkiDroid, the message is less verbose: *Syncing error, type 400 message: *


Attempted Solutions:

  • Disabling addons and using Check Database does nothing. Choosing not to sync media/images does nothing.

  • Upgrading to the latest version of Anki on Desktop. Error still persisted.

  • Reinstalled and downgraded back to version 2.1.24. No fix.

  • Created a new Ankiweb account and synced to that, also no fix.

  • Uploading backups from May - December 2020 results in the same error (which is odd because if this was an issue with the way I recently edited anything, any issues with the collection should have been solved with a November backup).


What Works for Anki on PC:

Creating a new profile, not importing my current collection to it (just added some basic-type cards for testing), and synced that to my new Ankiweb account – it syncs normally.

If I delete all the decks in my collection, and sync only cards I just added and reviewed in my default deck, it syncs normally.

But after opening numerous backups and trying to add a new card using a non-default template to a fresh profile – it will not sync normally even if I add a new card after deleting every deck. I have to open another profile to attempt further troubleshooting.

I also tried to transfer cards from my other decks into the Default one in hopes that it might fix something, but the error still appears.


Note: Anki will sync new media “normally” as long as I’ve not reviewed any cards – but it will not sync any new cards even if I don’t review anything.


Recreating all my cards from scratch is simply not feasible. I’ve put a lot of time into studying these decks and am concerned that one day I may not be able to depend on forcing syncs.

Importing collection backups from Feb - April 2020 appear to potentially solve the syncing issue. Is there some way I can merge my recent data into an older backup like this (by merging the records of the two *.db2 files somehow)? I’m relatively comfortable using DB Browser for SQLite, but am not very comfortable with Anki’s particular data structures.

Is there something else I could do that might solve the issue and preserve my data? Would upgrading Ubuntu help?

(Edited to fix formatting/grammar)

You have bad data in your collection, probably from an add-on you used about a year ago. The following in the debug console will remove it, and then you’ll need to upload to AnkiWeb.

mw.col.db.execute("delete from revlog where type > 4")
mw.col.modSchema(check=False)

https://docs.ankiweb.net/#/misc?id=debug-console

2 Likes

It’s fixed now, thank you so much for your help!

I was experiencing very similar symptoms to what @OblivionWing described, and tried the same fix you suggested, and it also worked for me. In case it’s helpful, I’m using Anki 2.1.38 on Ubuntu 20.04, and the only add-on I use is “Syntax Highlighting for Code”.

Hello

I did try the above debugging. Which worked at first, but as soon as I made new cards, that the same Error sign came up again. Any other recommendations?

Thanks again!

Please upgrade to the latest Anki version, use Check Database and a full sync, and then try again.