DEV Community

loading...

Discussion on: How to properly close a port?

Collapse
richardherbert profile image
Richard Herbert

I always have an issue with port 80. The macOS just doesn't want to let it go for non-root users.

Do you have any further suggestions as your script doesn't seem to work for me.

Collapse
sylwiavargas profile image
Sylwia Vargas Author

Yeah. I had a port 80 problem when Dropbox was running in the background. As soon as I changed that (i.e. now Dropbox only runs when I open it instead of when I switch the laptop on), my problem was fixed. You can see what occupies your port 80 by running sudo lsof -i :YourPortNumber.
changing your root permissions? unix.stackexchange.com/questions/1...

Collapse
richardherbert profile image
Richard Herbert

Yes, I've tried the DropBox trick but still macOS won't let my process use port 80 unless I start that process as root.

Not sure how that link you offered helps?

Thread Thread
sylwiavargas profile image
Sylwia Vargas Author

Eh how annoying. Well you could add root permissions to other users and then you should be able to close the port.

Thread Thread
richardherbert profile image
Richard Herbert

Ah, is that what that link was about?

Thread Thread
sylwiavargas profile image
Thread Thread
richardherbert profile image
Richard Herbert

Okay, I’ll take a closer look and let you know how I get on.

Thanks for your help.

Thread Thread
richardherbert profile image
Richard Herbert

@sylwia - That link seemed to be about file permissions rather than process permissions.

See my reply to Mateusz where I use the insight provided and find my solution,

Collapse
mateuszjarzyna profile image
Mateusz Jarzyna

I’s standard, security behavior. You cannot open port <1024 as standard user, you need root permision on both macOS and Linux systemy. Because of security.

When someone will hack into your server, the hacker cannot kill your HTTP server and run phishing site on you domain because he need root privilages.

Collapse
richardherbert profile image
Richard Herbert

Well, that makes sense.

Armed with this knowledge I researched port forwarding and discovered pf (packet filtering) which lead me to salferrarello.com/mac-pfctl-port-f... which was the answer to my issue.

Thanks for the insight!