How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’

I have the following error in the Chrome Dev Tools console on every page-load of my Node/Express/React application:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

This error makes a reference to localhost/:1. When I hover over this, it shows http://localhost:3000/, the address I’m viewing the app at in the browser.

Anyone have an idea what is going on? Most of the other threads I’ve found that bring up this error seem to be related to someone trying to develop a Chrome Extension, and even then they tend to have very few responses.

18 Answers

I’d been getting the exact same error (except my app has no back-end and React front-end), and I discovered that it wasn’t coming from my app, it was actually coming from the “Video Speed Controller” Chrome extension. If you aren’t using that extension, try disabling all of your extensions and then turning them back on one-by-one?

The error is often caused by a chrome extension. Try disabling all your extensions, the problem should disapear.

Solution

For Chrome:

  1. You have the window open with the console error, open up a second new window.

  2. In the second window, go to: chrome://extensions

  3. Disable each extension by toggling (the blue slider on the bottom right of each card), and refresh the window with the console after toggling each extension.

  4. Once you don’t have the error, remove the extension.

I found the same problem when developing the Chrome extensions. I finally found the key problem.

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

The key problem is that when background.js sends a message to the active tab via chrome.tabs.sendMessage, the content.js on the page is not ready or not reloaded. When debugging. We must ensure that content.js is active. And it cannot be a page without refreshing , The old pages don not update you js itself

Here is my code:

//background.js
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
  chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) {
      console.log(response);
  });
}); 


//content.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
    console.log(request, sender, sendResponse);
    sendResponse('我收到你的消息了:'+JSON.stringify("request"));
});

If you are an extension developer see this Chrome Extension message passing: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

The core of the problem is that chrome API behavior change and you need add a workaround for it.

Removing ‘Udacity Frontend Feedback’ chrome extension solved the issue for me.

This was happening in Chrome for me and I discovered it was McAfee WebAdvisor. Once I disabled it, the message went away: enter image description here

You just need to handle window.chrome.runtime.lastError in the runtime.sendMessage callback. It’s as simple as that, nothing fancy. I had spent lots of time fixing it and finally realized that this error just needs to be handled. Below is my code:

window.chrome.runtime.sendMessage(
      EXTENSION_ID,
      { message:"---" }, // jsonable message
      (result) => {
        if (!window.chrome.runtime.lastError) {
          // do you work, that's it. No more unchecked error
        }
      }
    );
  });

It was tab bnundler for me: https://chrome.google.com/webstore/detail/tab-bundler/ooajenhhhbdbcolenhmmkgmkcocfdahd

Disabling the extension fixed the issue.

For me the error was due to the onelogin chrome extension. Removing it fixed the issue.

Cacher Extension in my case – but yeah disable each and then reload page

It was a few extensions for me. Disabling and then re-enabling fixed the problem though. Grammarly was one of them. Hope the errors don’t return.

I was testing my extension on edge://extensions/ page/tab. Testing it on another tab solved this issue. I think this may also occur for chrome://extensions/.

Oddly enough, for myself I simply disabled all my extensions and the error went away.

However, after re-enabling all of the ones I disabled, the error was still gone.

This is usually caused by an extension.

If you don’t want to disable or remove the extension which causes this error, you can filter out this specific error by typing -/^Uncheckedsruntime.lastError:sCouldsnotsestablishsconnection.sReceivingsendsdoessnotsexist.$/ in the Filter box in the console:

Example

Example #2

As far as I’ve seen, this filter will stay until you remove it manually, you can close and reopen the console, restart Chrome, etc as much as you want and the filter will never be removed automatically.

I get the message only on the first Chrome page =
When Chrome is not running, and I open it – either directly or by double-clicking on a page on my desktop.
(I don’t know if this matters, but I have “Continue running background apps when Google Chrome is closed” off.)
So, I’m assuming it’s Chrome’s crap spying/”enhancing user experience” attempt.
I don’t know what it’s trying to send, but I’m glad it’s not able to! 🙂
So, second (or any but first) tab has no error.
== No need to disable anything (extensions, etc.).

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.


I “achieved” this error after

  1. installing the Debugger for Chrome extension in Visual Studio Code,
  2. debugging my code, and
  3. closing and reopening the non-debugging Chrome window. (I had left Chrome running my app while debugging.)


Solutions:

  • Stop using the extension.
  • Refresh the non-debugging Chrome window.
  • Use a different debugger.

Of course, the console error reappears when I redo steps 2 and 3 above with the Debugger for Chrome. This encourages me to use other debuggers instead. Then I don’t mistakenly think my own code produced the console errors!

For me this was caused by :

Iobit Surfing Protection & Ads Removal extension

which comes with Iobit advanced system care software. However, the console might provide you with relevant information on what you need do disable or the cause for that problem.

The likely cause of this error, as per google searches is because that extension which causes the error, might be using the chrome.runtime.sendMessage() and then tries to use the response callback.

Error shown in the console

Hope this information helps. Have a great day!


Leave a Reply

Your email address will not be published. Required fields are marked *