# How to run Node-RED on Windows 10 WSL (Linux Subsystem)

**URL:** <https://discourse.nodered.org/t/how-to-run-node-red-on-windows-10-wsl-linux-subsystem/45032>\
**Category:** FAQs\
**Tags:** windows\
**Created:** [1 May 2021 19:54 UTC](https://discourse.nodered.org/t/how-to-run-node-red-on-windows-10-wsl-linux-subsystem/45032 "2021-05-01T19:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 May 2021 19:54 UTC](https://discourse.nodered.org/t/how-to-run-node-red-on-windows-10-wsl-linux-subsystem/45032/1 "2021-05-01T19:54:58Z")

</div>

Windows 10 has a feature that allows you to run Linux in a lightweight virtual container.

WSL allows easy access to and from Windows/Linux filing systems.

It runs a special version of the Linux kernel to achieve tight integration with Windows. You may install a number of different Linux distributions from the Windows Store, Ubuntu being the original and probably best developed. You cannot (yet) easily run a Linux desktop but this should be integrated in 2021H2. In addition, WSL does not use systemd as most distributions now do.

* * *

#### How to install Node.js and Node-RED

1. Install node.js from the [official installation page](https://nodejs.org/en/download/). If you are using a Debian-based distribution on WSL, I strongly recommend using the [NodeSource binary distributions](https://github.com/nodesource/distributions/blob/master/README.md).

2. Install Node-RED using `npm -g install node-red` or my [alternate-node-red-installer](https://github.com/TotallyInformation/alternate-node-red-installer).

3. Start node-red

4. **Panic** because you now don't know how to access the started web server!

It is OK, no need for panic. Microsoft have crafted some magic so that `localhost` (AKA `127.0.0.1`) on WSL is mapped over to the same on the Windows host.

But now something really weird happens. You can start Node-RED on the host and in WSL - with the same PORT! When you do, the WSL version takes preference.

* * *

Incidentally, because WSL is a virtual environment, it has its own virtual network interface (It actually uses Hyper-V) with its own IP address, something in the range `172.20.*.*`. Unfortunately, this may not be the same address every time WSL is started. ☹ I add the following to my `~/.bashrc` script in WSL so that I can see the IP address every time I start it:

```auto
export WSL_IP=`ip route get 1 | awk '{gsub("^.*src ",""); print $1; exit}'`
echo "WSL Local IP Address: $WSL_IP"

```

This has an impact if you want to make your WSL-based service available from _outside_ the host (e.g. from a different device). In that case, you will need to [look up the various work-arounds](https://github.com/microsoft/WSL/issues/4150) that have been published that grab the IP address and create firewall forwarding rules.

* * *

**PS** : If you are going to the trouble of using WSL on Windows, you will almost certainly want a couple of other things as well:

- Microsoft Terminal - this is the new windows terminal and beats the pants of the one that comes with Windows. Install via the Windows Store.

- **VSCode** - This free IDE/Code Editor is open source but backed by Microsoft. Microsoft have produced a number of extensions including some remote editing extensions for WSL, Docker and SSH.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 May 2021 20:20 UTC](https://discourse.nodered.org/t/how-to-run-node-red-on-windows-10-wsl-linux-subsystem/45032/2 "2021-05-01T20:20:52Z")

</div>

And of course, as soon as you publish something like this, you discover more info.

You can find out the IP address of WSL from the host with the command `wsl hostname -I`. The address is stable for a specific instance of WSL and it will change on a system reboot or a fully shutdown/termination of WSL. Different Linux distributions will have different WSL instances and therefore different IP addresses.

[windows 10 - Make IP address of WSL2 static - Super User](https://superuser.com/questions/1582234/make-ip-address-of-wsl2-static)

* * *

And another quick tip. This bash script will copy your WSL IP address with Node-RED's default port into the Windows clipboard! You could even run this at WSL startup by adding to `~/.bashrc`

```auto
#!/bin/bash
hostname -I | awk '{print $1}' | awk '{printf "%s:1880", $0}' | clip.exe

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 May 2021 19:55 UTC](https://discourse.nodered.org/t/how-to-run-node-red-on-windows-10-wsl-linux-subsystem/45032/3 "2021-05-31T19:55:07Z")

</div>

This topic was automatically closed after 30 days. New replies are no longer allowed.
