# Error after changing port

**URL:** <https://discourse.nodered.org/t/error-after-changing-port/43582>\
**Category:** General\
**Created:** [3 April 2021 00:16 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582 "2021-04-03T00:16:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [3 April 2021 00:16 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/1 "2021-04-03T00:16:55Z")

</div>

I would like Node-RED to listen on port 443.

I changed

```auto
uiPort: process.env.PORT || 1880,

```

to

```auto
uiPort: 443,

```

and also tried

```auto
uiPort: process.env.PORT || 443,

```

but in both cases I got this error when trying to start Node-RED:

 ![Screen Shot 2021-04-02 at 5.29.10 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e5ac447277cfe40b8b0ce51604ca79546ce3d8f.png)

I already tried running

```auto
sudo lsof -i -P -n | grep LISTEN

```

to confirm that port 443 is not in use.

Ubuntu 20.04  
Node v12.22.0  
Node-RED v1.2.9

edit: by the way, I do have SSL working. Used these instructions:

> [@Node-RED SSL using Letsencrypt & Certbot](https://discourse.nodered.org/t/node-red-ssl-using-letsencrypt-certbot/17606):
>
> I've written this up in case it helps other who may wish to secure their node-RED online presence, by using SSL certificates. The installation uses Letsencrypt to issue the certificates and also Certbot to fully automate and handle renewals - so it's a fit & forget solution. Pre-requisites I've started with a RPi3b+ and a fresh 'Buster' operating system, with node-RED installed via the official script. Because node-RED is going to provide my online presence, no other webserver (such as apach…

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [3 April 2021 01:01 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/2 "2021-04-03T01:01:30Z")

</div>

The error message in the log indicates permission issue. The reason is that it is necessary root privilege's to use ports below 1024.

Some references:

> [@Raspberry Pi and UDP?](https://discourse.nodered.org/t/raspberry-pi-and-udp/7129/2):
>
> The error is exactly what it says: If you want to use a port number \< 1024, you need to run as root. We generally recommend not to run as root, so if you can, pick a port higher than 1024.

> [@Problems to open port 162 (SNMP-TRAP)](https://discourse.nodered.org/t/problems-to-open-port-162-snmp-trap/31555):
>
> I want to use node-red-contrib-snmp-trap-listener to receive traps via snmp, on port 162, but I get this error "can't open port: 162". I have the same problem with node-red-contrib-syslog, which uses port 514. I have read that only the root user can open privileged ports (1-1024). Is there any way for node-red to open privileged ports without error? Best regards

> [@Modbus TCP Server on port 502](https://discourse.nodered.org/t/modbus-tcp-server-on-port-502/4760/3):
>
> Not to bump an old thread, but for anyone who comes searching, the most likely culprit is needing root access to listen on a port less than 1024, assuming you're running Node-RED on a Linux device.

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [3 April 2021 01:14 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/3 "2021-04-03T01:14:07Z")

</div>

Thanks - that explains it.

While I see options there to get around the permissions issue, it seems like it makes more sense to use NGINX reverse proxy to solve this issue. Then, I think, I can also do things like redirect requests on port 80 to 443, or perhaps accept requests both ways. Neither of which I believe I can do with Node-RED alone.

I found this guide. Do you think this would put me on a better track? [Node-red server with nginx reverse proxy howto guide](https://discourse.nodered.org/t/node-red-server-with-nginx-reverse-proxy-howto-guide/27397)

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [3 April 2021 04:50 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/4 "2021-04-03T04:50:40Z")

</div>

@quarfie wrote: ".....or perhaps accept requests both ways"

**Redirect 80 to 443** - Accepting requests on port 80 for services exposed to external networks (the big bad internet) is a bad idea.

**the guide** - if you have questions just ask.

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [3 April 2021 18:05 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/5 "2021-04-03T18:05:02Z")

</div>

Thanks, @meeki007

I run into trouble when I try to `sudo apt install nginx`

```auto
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nginx : Depends: libssl1.0.0 (>= 1.0.2~beta3) but it is not installable
E: Unable to correct problems, you have held broken packages.

```

I'm unsure if it's related, but when I `sudo apt update`, I get a couple 404s:

```auto
Hit:1 http://ca-central-1.ec2.ports.ubuntu.com/ubuntu-ports focal InRelease
Hit:2 http://ca-central-1.ec2.ports.ubuntu.com/ubuntu-ports focal-updates InRelease                                        
Hit:3 http://ca-central-1.ec2.ports.ubuntu.com/ubuntu-ports focal-backports InRelease                                      
Hit:4 https://deb.nodesource.com/node_12.x focal InRelease                                                                 
Ign:5 http://ppa.launchpad.net/certbot/certbot/ubuntu focal InRelease                                                      
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                
Hit:7 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease                                                        
Hit:8 http://nginx.org/packages/ubuntu xenial InRelease                                                                    
Err:9 http://ppa.launchpad.net/certbot/certbot/ubuntu focal Release             
  404 Not Found [IP: 91.189.95.85 80]
Ign:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [310 kB]
Ign:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
Ign:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
Ign:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
Ign:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
Err:10 http://security.ubuntu.com/ubuntu bionic-security/main arm64 Packages
  404 Not Found [IP: 91.189.88.152 80]
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/certbot/certbot/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

```

---

<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:** [3 April 2021 19:44 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/6 "2021-04-03T19:44:09Z")

</div>

Try  
`sudo apt full-upgrade`  
And if that doesn't help then  
`sudo apt install -f`

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [3 April 2021 20:19 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/7 "2021-04-03T20:19:41Z")

</div>

Thanks, but there was no change after running these.

---

<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:** [3 April 2021 20:28 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/8 "2021-04-03T20:28:30Z")

</div>

I am at my PC now and looked at your output more carefully. Your sources list is a complete mess. You are running Ubuntu 20.04 (which is focal), but you have a xenial (16.04) source for nginx (that is no doubt the primary reason for the nginx install problem) and a whole set of bionic ones (18.04). Finally the certbot ppa you have specified does not support 20.04. I suggest you edit your sources list and start by getting rid of all the xenial and bionic ones and then try  
`sudo apt update`  
`sudo apt full-upgrade`  
and then see where that gets you.  
Once everything else is sorted then you can look at the certbot ppa. Why are you using that?

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [3 April 2021 22:55 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/9 "2021-04-03T22:55:06Z")

</div>

Good questions. Although I don't know the answers you inspired me to blow it up and start over using @meeki007's tutorial, which is really excellent and way better than the resources I was trying to follow the first time.

And everything is working perfectly.

Thank you!

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [3 April 2021 23:09 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/10 "2021-04-03T23:09:04Z")

</div>

Awesome! glad its working. Thanks Colin for stepping in when i was away.

Hey Breaking things "blow it up and start over" is how I learn 90% of the stuff I'm working on. Now and again I think back to times before and the amount of resources/time lost because you could not just delete a line or reinstall.

Well I'll just throw away 10,000 copies of that pamphlet because it was printed on green paper stock instead of red.

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [4 April 2021 02:41 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/11 "2021-04-04T02:41:15Z")

</div>

One issue with Nginx... the value of msg.req.ip is 127.0.0.1... can Nginx pass through the original IP?

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [4 April 2021 02:53 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/12 "2021-04-04T02:53:32Z")

</div>

yes! that is what:

```auto
#Forwards the real visitor remote IP address to the proxied server
		        proxy_set_header X-Real-IP $remote_addr;

```

in the nginx hosts is for.

node-red, dashboard, and worldmap all support this. using the stock node-red look in the msg.[somting?].headers section to see the ip of the user connected.

as for other nodes they may or may not handle proxy correctly.

Update:  
msg.req.headers["x-real-ip"] is what your looking for.

---

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [4 April 2021 03:54 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/13 "2021-04-04T03:54:24Z")

</div>

Amazing. Thanks again.

---

<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:** [18 April 2021 03:55 UTC](https://discourse.nodered.org/t/error-after-changing-port/43582/14 "2021-04-18T03:55:20Z")

</div>

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