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

node.jsGoogle Chrome-Devtools

node.js Problem Overview


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.

node.js Solutions


Solution 1 - node.js

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?

Solution 2 - node.js

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"));
});

Solution 3 - node.js

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

Solution 4 - node.js

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][1] [1]: 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.

Solution 5 - node.js

If you are an extension developer see this https://stackoverflow.com/questions/54181734/chrome-extension-message-passing-unchecked-runtime-lasterror-could-not-establi/54686484#54686484

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

Solution 6 - node.js

You need to handle window.chrome.runtime.lastError in the runtime.sendMessage callback. 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) {
           // message processing code goes here
        } else {
          // error handling code goes here
        }
      }
    );
  });

Solution 7 - node.js

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

Solution 8 - node.js

simple answer:

if you have no response from another End it will also tell you Receiving end does not exist.

detailed answer:

if you have no answer from another end it will also tell you Receiving end does not exist. so if you have any callBack function which should use response in your .sendMessage part, you should either delete it or handle it if you probably have no response from another side.

so

if i wanted to re-write Simple one-time requests section of Message passing documents of google API i will write it with error handlers for callback functions in message-sending methods like this:

Sending a request from a content script looks like this:

chrome.runtime.sendMessage({greeting: "hello"}, function (response) {
    if (!chrome.runtime.lastError) {
        // if you have any response
    } else {
        // if you don't have any response it's ok but you should actually handle
        // it and we are doing this when we are examining chrome.runtime.lastError
    }
});

Sending a request from the extension to a content script looks very similar, except that you need to specify which tab to send it to. This example demonstrates sending a message to the content script in the selected tab.

chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
  chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) {
    if (!chrome.runtime.lastError) {
        // if you have any response
    } else {
        // if you don't have any response it's ok but you should actually handle
        // it and we are doing this when we are examining chrome.runtime.lastError
    }
  });
});

On the receiving end, you need to set up an runtime.onMessage event listener to handle the message. This looks the same from a content script or extension page.

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    console.log(sender.tab ?
                "from a content script:" + sender.tab.url :
                "from the extension");
    if (request.greeting === "hello")
      sendResponse({farewell: "goodbye"});
  }
);

Solution 9 - node.js

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

Solution 10 - node.js

I removed "Video Speed Controller" Chrome Extension and the error was removed. It worked for me like this. In your case there may be some other extensions too which may cause this error.

Solution 11 - node.js

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

Disabling the extension fixed the issue.

Solution 12 - node.js

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.

Solution 13 - node.js

This is caused simply by installed chrome extensions, so fix this first disable all chrome extensions then start to enable one after another to detect which extension is cause you can enable the remaining.

Solution 14 - node.js

in my case removing 'adblocker youtube' extension work for me

Solution 15 - node.js

The simple fix is to return true; from within the function that handles chrome.tabs.sendMessage. It's stated here.

(this is similar to other answers)

Solution 16 - node.js

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

Solution 17 - node.js

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

Solution 18 - node.js

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.

Solution 19 - node.js

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/.

Solution 20 - node.js

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 -/^Unchecked\sruntime\.lastError\:\sCould\snot\sestablish\sconnection\.\sReceiving\send\sdoes\snot\sexist\.$/ 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.

Solution 21 - node.js

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.).

Solution 22 - node.js

>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!

Solution 23 - node.js

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!

Solution 24 - node.js

In my case, I removed the Adblocker Youtube extension in my browser. It solved the problem for me.

Solution 25 - node.js

For chrome extension development, it's an error thrown by chrome.tabs.sendMessage method.

Here is the link of related documentation: https://developer.chrome.com/docs/extensions/reference/tabs/#method-sendMessage. In the link you can find the description for the callback function: If an error occurs while connecting to the specified tab, the callback is called with no arguments and runtime.lastError is set to the error message.

According to documentation above, the error is because of the specified tab. I restart chrome and reloaded the extension, and this issue is fixed

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEmilioView Question on Stackoverflow
Solution 1 - node.jsfrederjView Answer on Stackoverflow
Solution 2 - node.jsGM GAMERView Answer on Stackoverflow
Solution 3 - node.jsGermanium CorporationView Answer on Stackoverflow
Solution 4 - node.jskai_ontherealView Answer on Stackoverflow
Solution 5 - node.jsDavid DehghanView Answer on Stackoverflow
Solution 6 - node.jsNiraj KumarView Answer on Stackoverflow
Solution 7 - node.jsjeevanView Answer on Stackoverflow
Solution 8 - node.jskia nasirzadehView Answer on Stackoverflow
Solution 9 - node.jshaakon.ioView Answer on Stackoverflow
Solution 10 - node.jsDeepinderView Answer on Stackoverflow
Solution 11 - node.jsmicnguyenView Answer on Stackoverflow
Solution 12 - node.jskrchunView Answer on Stackoverflow
Solution 13 - node.jsTheodoryView Answer on Stackoverflow
Solution 14 - node.jsMuhammad AzeemView Answer on Stackoverflow
Solution 15 - node.jsRyanView Answer on Stackoverflow
Solution 16 - node.jsBitclawView Answer on Stackoverflow
Solution 17 - node.jskonikView Answer on Stackoverflow
Solution 18 - node.jsEliezer SteinbockView Answer on Stackoverflow
Solution 19 - node.jsbantyaView Answer on Stackoverflow
Solution 20 - node.jsDonald DuckView Answer on Stackoverflow
Solution 21 - node.jsiAmOrenView Answer on Stackoverflow
Solution 22 - node.jsSuper JadeView Answer on Stackoverflow
Solution 23 - node.jsSharon ShajiView Answer on Stackoverflow
Solution 24 - node.jsMAM.AASIMView Answer on Stackoverflow
Solution 25 - node.jspoorguyView Answer on Stackoverflow