# "Lost Connection to server" on Ubuntu

**URL:** <https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860>\
**Category:** General\
**Created:** [14 November 2018 10:52 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860 "2018-11-14T10:52:03Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![coster](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@coster](https://discourse.nodered.org/u/coster)\
**Post date:** [14 November 2018 10:52 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/1 "2018-11-14T10:52:03Z")

</div>

Hallo,  
installed node-red on a fresh ubuntu 18.04 system:

sudo npm install -g --unsafe-perm node-red

after starting it, I got the error:

"Lost connection to server, reconnecting in ..."

In Javascript console:  
red.min.js:16 WebSocket connection to 'ws://node.brantner.loc:1880/comms' failed: Error in connection establishment: net::ERR\_NAME\_NOT\_RESOLVED  
r @ red.min.js:16

What did I do wrong or what did I forget?

Thank you, Christian.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 November 2018 11:40 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/2 "2018-11-14T11:40:03Z")

</div>

Can you post the node-red startup log (That's the output starting "Welcome to node red")

You may be interested to know that on Ubuntu you can install using the Pi install script from [https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi) which should guarantee you get a consistent set of tools. That is what I always do. If you wanted to do that don't worry about the fact you have already installed it, the script should tidy it up.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 November 2018 11:42 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/3 "2018-11-14T11:42:46Z")

</div>

Are you running this machine behind any kind of proxy? If so, you must make sure the proxy is configured to allow websocket connections through.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 16:45 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/4 "2018-11-14T16:45:47Z")

</div>

I just tried the script on a fresh 18.04 install. Chose N for "Pi specific nodes" it failed at the install node.js LTS step.

I had installed build essentials and some other development tools. From the log files it looks like npm is not installed. Perhaps the script should apt-get install npm if not on a Pi?

It seems to have installed fine when repeated after installing npm (which brings in a lot of stuff on Ubuntu-Mate 18.04)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 November 2018 17:00 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/5 "2018-11-14T17:00:31Z")

</div>

> [@wb666greene](#):
>
> it failed at the install node.js LTS step.

Can you post the install log please from the failing run please. It should still be in the file unless you deleted it. There must be some condition not coped with.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2018 17:18 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/6 "2018-11-14T17:18:52Z")

</div>

which version of node.js did it install ?

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 19:21 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/7 "2018-11-14T19:21:08Z")

</div>

I'm sorry, it got over-written by the successful install after I installed npm. Actually it seems to have appended, but the very start of the file doesn't look quite right. [nodered-install.log.txt](https://discourse.nodered.org/uploads/short-url/oriCZNqbpYNZgDNnf6luqEXwnGF.txt) (22.6 KB)

I've ended up with npm --version 3.5.2 and nodejs --version 8.10.0 on this Ubuntu 18.04 system.

I haven't done anything with it yet other than manage pallet to add the dashboard, seems to have worked.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2018 19:57 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/8 "2018-11-14T19:57:56Z")

</div>

The weirdness is that it says it installed nod from [https://dl.bintray.com/resin-io/debian](https://dl.bintray.com/resin-io/debian) stable Release: which would indicate it didn't use the correct nodejs version. Indeed 8.10.0 that you now have is slightly backlevel also...

How did you get nodejs installed ? the links from the nodejs site take you to

> <https://github.com/nodesource/distributions/blob/master/README.md>

  
We still recommend the 8.x version (though 10.x should also work fine... but please don't use 11.x yet)

That should get you node 8.12.0 and npm 6.4.1 I think (as of 14th Nov 2018)

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 20:14 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/9 "2018-11-14T20:14:30Z")

</div>

I used the script with the curl command cut and pasted from the Raspberry Pi installation page:  
[https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi)

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

```

I re-ran the script a third time and it says: Leave Existing Node v8.10.2 Npm 3.5.2 I was hoping maybe it'd pull in the "correct" versions. Seems not.

I'm really hoping this snap/docker/appimage stuff works out and one format can dominate. With TB hard drives in the end-caps at MicroCenter for $25, IMHO the savings from using shared libraries are not worth hassles of library and subsystem versionitis incompatibilities.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 November 2018 20:33 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/10 "2018-11-14T20:33:40Z")

</div>

> [@dceejay](#):
>
> The weirdness is that it says it installed nod from [https://dl.bintray.com/resin-io/debian](https://dl.bintray.com/resin-io/debian) stable Release

Is that correct? I see  
`Get:3 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 nodejs amd64 8.10.0~dfsg-2ubuntu0.4`

But I am wondering whether this is actually the problem:

```auto
W: GPG error: https://dl.bintray.com/resin-io/debian stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 379CE192D401AB61
E: The repository 'https://dl.bintray.com/resin-io/debian stable Release' is not signed.
Error executing command, exiting

```

Did that mean that it exited the command before setting up the nodejs repo?  
@wb666greene could you sort out that error (either get the key for bintray or disable that repository), uninstall nodejs and try the script again?  
Before running the script run  
`sudo apt update && sudo apt full-upgrade`  
to make sure all packages are up to date that there are no other problem with your repositories.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2018 20:42 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/11 "2018-11-14T20:42:02Z")

</div>

We do now have a snap version as well. Of course you need to stop the existing one as it also uses port 1880 by default ( but can be changed)

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 20:55 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/12 "2018-11-14T20:55:04Z")

</div>

Interesting, initially while checking out Mate's "software boutique" I tried to install Etcher SD/USB imager and it failed for lack of the key. I thought it a bug in the boutique. I didn't really need Etcher on this system so I ignored it after posting a message about the error on the Ubuntu Mate forum.

I've removed the repo from software sources, did apt-get remove nodejs, and re-ran the script, now I get a popup saying npm update check failed and something I really don't understand about a local update config store with a recommended sudo command. So I did the command.

Looks like I now have nodejs 8.12.0 and npm 6.4.1

Thanks, I don't think it really mattered for my purposes, but I'm happy to try and help out so that the process can be improved such that non-apprentice gurus can expect it to work.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 November 2018 21:00 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/13 "2018-11-14T21:00:56Z")

</div>

Did you do the apt update && full-upgrade command first?

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 21:10 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/14 "2018-11-14T21:10:39Z")

</div>

I will likely move to the snap eventually, but I wanted this system to be as similar to my Raspbian Stretch setup as practical.

I have a nodejs program, that depends on some non-standard npm installed contrib libraries, which scans the network for the URLs of Onvif network cameras. If I spawned it using an exec node with node-red running in a snap, would that external command still work? On the other hand I only need to run the command when cameras are changed so it'd be more "natural" to run it outside of node red. Would I then have to install a "parallel" nodejs and npm using apt-get to do so?

Finding out some time in the future, after I've long forgotten these details, that moving a command that has worked well externally into the snap node-red flow as part of some "upgrade" I dream up stopped working would be a real bummer and a factor against using snaps.

I'm thinking out loud as I don't yet appreciate the restrictions of using snaps although they are starting to sound like the holy grail to me 🙂 if my speculation of a potential issue mention above is unfounded I'll look into the snap version sooner rather than later.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2018 21:18 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/15 "2018-11-14T21:18:44Z")

</div>

Well we are all learning about snaps so yes it would be a good thing to test/try. One of the things they do have in the pipeline (1Q19 hopefully) - is the ability to base one snap on another (more dependencies yay,,,, 🙂 - so you could take our Node-RED snap and add your own extras and customisations to it.

Anyway - back to today - is the external command something we can try ?

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [14 November 2018 22:49 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/16 "2018-11-14T22:49:26Z")

</div>

Sure if you have an Onvif camera for it to find. Its pretty simple and bare bones, I'm a javascript newbie. It requires node-onvif (contrib, there are two with similar names) and fs, which I think is part of the installation.

I've attached it, rename to remove the .txt added so I could upload it, and run with nodejs onvif\_discover.js  
[onvif\_discover.js.txt](https://discourse.nodered.org/uploads/short-url/9q6lSjfpCtilbmwtwIwetFjHP0F.txt) (4.3 KB)

I've never actually ran it with no cameras so it could die horribly.

Its purpose it to make a list of the camera URLs and write it to a file, which my Python AI script loads on startup. This Python script is launched by node-red exec via a shell script which sets up some log files and starts the Python code.

I couldn't make heads or tails with the Python onvif module so I used nodejs, which I need to learn more about so this was a good place to start.

---

<div class="post-metadata">

**Author:** ![coster](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@coster](https://discourse.nodered.org/u/coster)\
**Post date:** [16 November 2018 06:13 UTC](https://discourse.nodered.org/t/lost-connection-to-server-on-ubuntu/4860/17 "2018-11-16T06:13:33Z")

</div>

Thank you knolleary, the proxy was the problem. Greetings, Christian.
