# Keeping flows with hostname change?

**URL:** <https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474>\
**Category:** General\
**Created:** [5 September 2020 13:51 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474 "2020-09-05T13:51:49Z")\
**Posts on this page:** 15\
**Page:** 1

<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:** [5 September 2020 13:51 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/1 "2020-09-05T13:51:50Z")

</div>

I clone a fair number of systems running my AI person detector. That part is easy, but when I change the hostname and reboot, I lose the running flow.

Any easy solution? I tried renaming the flows\_hostname.json file but it didn't work. Do I need it do it when I change the hostname, before I reboot?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 September 2020 14:25 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/2 "2020-09-05T14:25:06Z")

</div>

If you specify the flow name in the command line it will always load that flow & therefore hostname is irrelevant.

```bash
>node-red --help
Node-RED v1.0.4
Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR]
                [--port PORT] [--title TITLE] [--safe] [flows.json]

Options:
  -p, --port PORT port to listen on
  -s, --settings FILE use specified settings file
      --title TITLE process window title
  -u, --userDir DIR use specified user directory
  -v, --verbose enable verbose output
      --safe enable safe mode
  -?, --help show this help

Documentation can be found at http://nodered.org

```

e.g. start node-red and specify the flow file...  
`node-red myflow.json`

* * *

Alternatively...  
Edit the settings.js file...

```auto
    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',

```

---

<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:** [5 September 2020 15:59 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/3 "2020-09-05T15:59:06Z")

</div>

> [@wb666greene](#):
>
> I tried renaming the flows\_hostname.json file but it didn't work

Which file did it try to open? Start it in a terminal to find out.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 September 2020 16:26 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/4 "2020-09-05T16:26:35Z")

</div>

Another way would be to use projects.

---

<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:** [5 September 2020 17:13 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/5 "2020-09-05T17:13:34Z")

</div>

It creates a .node-red/flows\_newHostName.json file. Copying the original flow into this didn't work

So far the only thing that worked is to past the original flow \*.json that I'd saved into the new flow.

My goal here is to clone the system, change the hostname and put the card into a new system and have it "just work" when it boots.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 September 2020 17:58 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/6 "2020-09-05T17:58:34Z")

</div>

I gave you 2 working solutions. Did you try either?

---

<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:** [5 September 2020 18:48 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/7 "2020-09-05T18:48:18Z")

</div>

I'm automatically launching node-red via systemd, I'm not hot to dive into how it is actually doing it, so changing the command line would be a last resort.

The second method suggests I wouldn't have the problem if the default flows file was flows.json instead of flows\_hostname.json.

On the next system I clone, I'll edit settings.js and un-comment flowFile to make it:

flowFile: 'flows\_{nameOfSystemBeingcloned}.json',

Presumably when the cloned system boots with the new hostname it'll then still use the original flows file.

Short answer, no, haven't tried it yet, but I will be cloning another system (AtomicPi) in a week or two. I'll follow up if it doesn't work.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 September 2020 18:49 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/8 "2020-09-05T18:49:52Z")

</div>

If you enter a static flow file name in settings.js then clone, it is done.

If you set a command line parameter for the system launch it'll work & be copied when cloned.

Both of these solutions care not if the host name changes.

---

<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:** [5 September 2020 18:54 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/9 "2020-09-05T18:54:37Z")

</div>

Editing the the settings.js file will be simple, figuring out how to make systemd launch it with a different command line parameter, not so much.

Systemd is something I hold my nose and just use, and since it generally "just works" I'm happy to ignore it, but when it goes wrong I end up cussing alot 🙂

---

<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:** [5 September 2020 18:57 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/10 "2020-09-05T18:57:22Z")

</div>

> [@wb666greene](#):
>
> It creates a .node-red/flows\_newHostName.json file. Copying the original flow into this didn't work

If you rename the old file as that name and start node-red what does it say then? If it says it is creating a new file then Deploy and see if it overwrites the file. I would put a small wager on the possibility that either you are looking in the wrong folder or there is a small error in the filename. Remember that if you are on a Linux system then file names are case sensitive.

---

<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:** [5 September 2020 19:05 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/11 "2020-09-05T19:05:58Z")

</div>

I'm trying to avoid post cloning futzing around beyond changing the hostname, which is not always necessary, and then I don't have any problem.

Steve-Mci's suggestion of editing the flows file to specify the original flowFile name seems perfect as I already have to edit the settings.js file to add some require() statements when I initially setup the system that I plan on cloning.

---

<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:** [5 September 2020 19:23 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/12 "2020-09-05T19:23:42Z")

</div>

I understand that, I just am never happy not understanding why something didn't work as it should. If it doesn't bother you then no problem.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [5 September 2020 19:25 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/13 "2020-09-05T19:25:03Z")

</div>

> [@wb666greene](#):
>
> I'm trying to avoid post cloning futzing around beyond changing the hostname, which is not always necessary, and then I don't have any problem.

If you're cloning the system, why not just use the same flow file name on every system? As suggested, rename the flows file to e.g. `flows.json` and edit the same name to `settings.js` ( **before** cloning). Then you'd have NR running straight away on a cloned system with or without changing the hostname.

---

<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:** [5 September 2020 19:37 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/14 "2020-09-05T19:37:16Z")

</div>

I didn't know how it was supposed to work which is why I asked. I've cloned enough systems that its been a constant irritation. I guess its possible I made a typo.

---

<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:** [4 November 2020 19:37 UTC](https://discourse.nodered.org/t/keeping-flows-with-hostname-change/32474/15 "2020-11-04T19:37:18Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
