AnkiConnect not working? Fixes that actually work
Short answer: AnkiConnect only answers while the Anki desktop app is open, after Anki has been restarted once since the add-on was installed. Check it by opening http://127.0.0.1:8765 in your browser. If nothing answers, the cause is Anki itself, the port, the firewall or — on a Mac — App Nap. If it answers but your tool is still refused, the cause is the add-on's allowed-origins setting, an API key, or a permission prompt waiting in Anki.
How to install and use AnkiConnect
- In the Anki desktop app, open Tools → Add-ons → Get Add-ons…
- Enter the code
2055492159and click OK. - Restart Anki when prompted. The add-on starts its server only when Anki starts, so skipping this step is the most common reason a fresh install “does nothing”.
- Leave Anki open while you use any tool that talks to it — a browser extension, a script, a dictionary app.
AnkiConnect then runs a small web server inside Anki, on your own computer only (address 127.0.0.1, port 8765). Tools send it requests such as “add these notes to this deck”. It is a desktop add-on: it does not exist for AnkiMobile or AnkiDroid, and it does nothing while Anki is closed.
The one-minute test
With Anki open, visit http://127.0.0.1:8765 (or http://localhost:8765) in your browser.
- A short line of text from AnkiConnect appears: the server is running. Skip to if it answers but your tool is refused.
- The browser says it cannot connect: nothing is listening. Work through the next section.
If nothing answers on port 8765
1. Anki is not open — or not fully started
Open Anki and wait for the deck list. Tools that use AnkiConnect cannot start Anki for you.
2. The add-on is not loaded
Open Tools → Add-ons and check that AnkiConnect is listed and enabled. If you just installed or updated it, restart Anki. If Anki shows an error about the add-on on start-up, update it: select it and click Check for Updates.
3. Your Anki is too old
The current AnkiConnect code refuses to start on Anki versions older than 2.1.45, and the README says it supports the latest stable releases. If you are on an old Anki, update Anki first, then the add-on.
4. macOS App Nap put Anki to sleep
When Anki is in the background on a Mac, App Nap can suspend it, and AnkiConnect stops answering. The README's fix is to run these three commands in Terminal and then restart Anki:
defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
defaults write net.ichi2.anki NSAppSleepDisabled -bool true
defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
5. A firewall is blocking Anki
On Windows, a firewall prompt may appear the first time Anki starts with the add-on. The README says Anki must be allowed for the add-on to work. If you dismissed the prompt, allow Anki in your firewall or security software and restart it.
6. Another program is using port 8765, or the port was changed
If another app already holds port 8765, AnkiConnect cannot listen there. The port is the webBindPort setting in the add-on's config. You can change it — but every tool you use must then be told the new port, and many, including Cardwright, always use 8765. Freeing the port is usually the better fix.
If it answers but your tool is refused
7. The allowed-origins list was edited
AnkiConnect only obeys requests from origins in its webCorsOriginList setting. The default list holds one entry, http://localhost, and according to the add-on's code that one entry also admits http://127.0.0.1 and browser-extension origins (chrome-extension://…, moz-extension://…). So with the default config, browser extensions do not need to be added by hand.
Problems start when someone replaces that entry — for example with a single website's address. Then extensions are refused too. To fix it, open Tools → Add-ons, select AnkiConnect, click Config, put "http://localhost" back into webCorsOriginList (keep any entries you added), save and restart Anki. Using "*" allows every website on your computer to control your collection — avoid it.
8. A permission prompt is waiting inside Anki
An origin that is not on the list can still send one request: requestPermission. Anki then shows a dialog titled “A website wants to access to Anki”, naming the origin. Click Yes and AnkiConnect adds that origin to webCorsOriginList and saves its config. The dialog may be hidden behind other windows — look at the Anki window.
9. You told Anki to ignore the tool
That dialog has an “Ignore further requests” checkbox. If it was ticked together with No, the origin went into ignoreOriginList and Anki stops asking. Remove the entry from ignoreOriginList in the config and restart Anki.
10. An API key is set
If apiKey in the config is not null, every request must include that key. Tools that do not send a key — Cardwright is one — will fail. Set it back to null unless you need it.
The default config, for reference
This is what Tools → Add-ons → AnkiConnect → Config shows on a fresh install. Restoring these values (and restarting Anki) undoes most self-inflicted problems:
{
"apiKey": null,
"apiLogPath": null,
"webBindAddress": "127.0.0.1",
"webBindPort": 8765,
"webCorsOriginList": ["http://localhost"],
"ignoreOriginList": []
}
webBindAddress set to 127.0.0.1 means only programs on the same computer can connect. Changing it to 0.0.0.0 exposes your collection to your network; you do not need that for a browser extension.
How Cardwright connects
Cardwright makes flashcards from text you highlight in Chrome, and its Send to Anki button uses AnkiConnect. Knowing exactly what it does helps match its messages to the fixes above:
- The first time you click Send to Anki, Chrome asks you to let Cardwright reach
http://127.0.0.1— your own computer, nothing else. If you decline, it shows “Cardwright needs permission to talk to the Anki app on your computer”. Click Send again and allow it. - It asks AnkiConnect for its version at
http://127.0.0.1:8765. No answer within a few seconds gives “Can't reach Anki. Is the Anki app open, with the AnkiConnect add-on installed?” Cardwright cannot tell “not running” from “running but refusing”, so if the one-minute test shows AnkiConnect answering, the cause is in fixes 7–10; otherwise it is 1–6. An API version older than 6 gives “Your AnkiConnect add-on is too old”: update the add-on. - It creates its own note types, “Cardwright Basic” and “Cardwright Cloze”, if they are missing, creates the deck, and adds the cards tagged
cardwright, skipping duplicates already in that deck. - If a step is refused, it sends
requestPermissionand tells you “Anki asked for confirmation — approve it in Anki, then click Send again.” That is fix 8.
Cardwright always uses port 8765 and does not send an API key. If Send to Anki cannot work on your setup, Export · Anki downloads a file with import headers instead — see how to import text into Anki. Every feature is free up to 25 cards and 3 decks, and cards already sent to Anki stop counting toward that limit; Pro is a one-time $4.99.
Questions
What is the AnkiConnect add-on code?
2055492159. In Anki, open Tools, Add-ons, Get Add-ons, paste the code, click OK and restart Anki when it asks.
Does Anki have to be open for AnkiConnect to work?
Yes. AnkiConnect is an add-on that runs inside the Anki desktop app. When Anki is closed, nothing is listening on port 8765 and every tool that uses AnkiConnect fails to connect.
How do I check whether AnkiConnect is running?
With Anki open, visit http://127.0.0.1:8765 in your browser. If a short text reply from AnkiConnect appears, the server is running. If the browser cannot connect, Anki is closed, the add-on is not loaded, or something is blocking the port.
Do I need to add my browser extension to webCorsOriginList?
Usually not. AnkiConnect's code accepts Chrome and Firefox extension origins as long as http://localhost is still in webCorsOriginList, which it is by default. You only need to change it if that entry was removed, or you can approve the permission prompt AnkiConnect shows inside Anki.
Does AnkiConnect work with AnkiMobile or AnkiDroid?
No. It is an add-on for the Anki desktop app on Windows, macOS and Linux. Add cards on the computer and sync them to your phone.