# AWS - start automatically

**URL:** <https://discourse.nodered.org/t/aws-start-automatically/41886>\
**Category:** General\
**Created:** [2 March 2021 10:40 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886 "2021-03-02T10:40:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [2 March 2021 10:40 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/1 "2021-03-02T10:40:41Z")

</div>

Hi,

I have a instance of node-red running on AWS.

Every time my EC2 gets rebooted Node-red stops, I have followed the instructions on [Running on Amazon Web Services : Node-RED](https://nodered.org/docs/getting-started/aws)

```auto
   sudo npm install -g --unsafe-perm pm2
   pm2 start `which node-red` -- -v
   pm2 save
   pm2 startup

```

I re-run the above and it starts up.

Any suggestions as the why it does not start up on its own?

Kind Regards

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [2 March 2021 11:10 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/2 "2021-03-02T11:10:51Z")

</div>

Assuming you are using Ubuntu you can use the systemd script to run Node-RED as a service and it will start on boot without pm2

[https://nodered.org/docs/getting-started/raspberrypi#autostart-on-boot](https://nodered.org/docs/getting-started/raspberrypi#autostart-on-boot)

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [2 March 2021 11:32 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/3 "2021-03-02T11:32:20Z")

</div>

> [@ScheepersJohan](#):
>
> `pm2 start `which node-red` -- -v`

It's a Ubuntu instance.

Thanks, I have tried it, not starting up

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [2 March 2021 11:39 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/4 "2021-03-02T11:39:33Z")

</div>

```auto
sudo npm install -g pm2
pm2 start `which node-red` -- -v
pm2 save
pm2 startup

```

Pay attention to the last command, you will have to execute another command (like: `sudo env PATH = $ PATH:/usr/bin/usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu`)

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [2 March 2021 11:45 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/5 "2021-03-02T11:45:13Z")

</div>

You should use the install script on the page I linked to, this will install Node-RED, NodeJS and the systemd script that can be used.

As I said there is no need for PM2 with this method.

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [2 March 2021 11:50 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/6 "2021-03-02T11:50:29Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c31298053c498b1ee4af47f6a209a80b3c3531b2.png)

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [2 March 2021 11:58 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/7 "2021-03-02T11:58:19Z")

</div>

Personally, I prefer to use PM2, because it also ensures the node-red autorestart (if there is a crash).

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [2 March 2021 12:04 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/8 "2021-03-02T12:04:22Z")

</div>

I used the PM2, but it does not restart on a EC2 reboot.

I don't know the path you are referring to.

```auto
sudo systemctl enable nodered.service

```

Does not work ether.

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [2 March 2021 12:07 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/9 "2021-03-02T12:07:38Z")

</div>

PM2 do restart in EC2 reboot. Most likely you are missing something (or you have another problem).

---

<div class="post-metadata">

**Author:** ![arlinfriesen](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arlinfriesen](https://discourse.nodered.org/u/arlinfriesen)\
**Post date:** [19 April 2021 16:57 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/10 "2021-04-19T16:57:32Z")

</div>

I'm having the same issue as well. PM2 isn't restarting my node-red in an EC2 reboot.

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [19 April 2021 21:01 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/11 "2021-04-19T21:01:32Z")

</div>

The only solution were to delete the EC2 and recreate a new instance.

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [20 April 2021 03:16 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/12 "2021-04-20T03:16:20Z")

</div>

Is the problem PM2 not starting or node-red not restarting ?

---

<div class="post-metadata">

**Author:** ![arlinfriesen](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arlinfriesen](https://discourse.nodered.org/u/arlinfriesen)\
**Post date:** [2 June 2021 18:58 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/13 "2021-06-02T18:58:52Z")

</div>

The issue was node-red not restarting. I wound up deleting the EC2 and recreating and that did solve the issue.

---

<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:** [1 August 2021 18:59 UTC](https://discourse.nodered.org/t/aws-start-automatically/41886/14 "2021-08-01T18:59:03Z")

</div>

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