How to run on port 80?

How can I get command box to run on port 80? When I try to run it on 80 I get this:

You asked for port [80] in your start params but it’s already in use so I’m ignoring it and choosing a random one for you.

netstat -tlnp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 790/sshd

tcp6 0 0 :::22 :::* LISTEN 790/sshd

tcp6 0 0 127.0.0.1:46297 :::* LISTEN 2311/java

tcp6 0 0 127.0.0.1:43963 :::* LISTEN 2311/java

It picks a random port. But as you can see from above I’m not using 80 for anything.

Thanks for any help.

There’s a good chance you’re not running as root, which is required to bind to a port south of 1024. The message you’re seeing is the generic response CommandBox gives if it can’t bind to that port. You can test this easily by attempting to bind to that port with Java from the CommandBox REPL.

Now, a warning-- CommandBox uses the user’s home dir as the root for where it unpacks itself into. If you are running commands both as :

box foo

and

sudo box foo

You’ll end up with two CommandBox homes which can be confusing if you’re not aware of what’s going on. If you’d like CommanBox to use the same home folder regardless of what user it’s running under, use the commandbox.properties trick shown here:

https://ortus.gitbooks.io/commandbox-documentation/content/setup/installation.html#installation

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

thanks for that info. Got that working. If I specify an IP in the start params it works just great.

I’m trying to run the server on localhost and allow any ip assigned from dhcp to connect to it. Any idea how to do this on debian?

The server for /root/pollmodbus/ is starting on http://127.0.0.1:80

Starting in background - pollmodbus [lucee 4.5.5+006] Server is up - http-port:80 stop-port:38139 PID:1155 version 3.6.100

Thank you for the help.

thanks for that info. Got that working. If I specify an IP in the start params it works just great.

I’m trying to run the server on localhost and allow any ip assigned from dhcp to connect to it. Any idea how to do this on debian?

The server for /root/pollmodbus/ is starting on http://127.0.0.1:80

Starting in background - pollmodbus [lucee 4.5.5+006] Server is up - http-port:80 stop-port:38139 PID:1155 version 3.6.100

but when I use an ip in a browser that is assigned it doesn’t find it .

Nathan,

As part of the server.json you can tell commandBox which IP to bind to. Don’t forget that 127.0.0.1 is only visible to your computer. You’ll need to bind it to the external facing IP (192.168.X.X or 10.x.x.xor whatever). If it’s DHCP, knowing what the actual IP is might be might be more complicated if it changes but that’s a separate (albeit related) issue.

Dan

By default, your servers will bind to localhost, which cannot be accessed from outside the machine. This is easy to fix. Just bind your server to the LAN IP, or 0.0.0.0 (all ips) and then you will be able to hit it (assuming no firewalls are in the way).

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

but when I use an ip in a browser that is assigned it doesn’t find it .

Yes, but that obviously wouldn’t work if the server is bound to localhost since localhost always refers to the local machine!

So if you have a server and you bind a port to 127.0.0.1 and then you try and hit 127.0.01 from your PC, your browser is going to try to connect to that IP on YOUR machine, not the server.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

thats not what i mean to say. i have server started on localhost. server has ip of 192.168.1.20.

if im on the server i can connect via localhost. but if i try to access it from a computer on the same network using 192.168.1.20 it wont connect.

I’m not sure what’s getting lost in the translation here. If you bind your CommandBox server to localhost or 127.0.0.1 then you CANNOT reach the server from outside of that machine. This isn’t a CommandBox limitation, it’s just how networking works.

If you want your server to be reachable from “outside” you need to set the “host” of your server to be an externally-accessible IP address or a host/domain name that resolves to one.

In all cases, setting the host to 0.0.0.0 will bind to ALL ips on the box which will be future proof and useful in cases like Docker where the IP can be unpredictable.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Oh man, I have the case of I’ve been staring at this too long I lost my mind.

Thanks so much for pointing that out. You really helped me out.