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:
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.
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).
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.
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.