Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Exposed port unavailable after a while

Hi! I'm very new to Apple, my first device is the Mac mini M1, I'm trying to expose some services (through Docker) but I currently have some problems.

I investigated a little more and I found that my problem is not related to docker, once I try to expose a port directly with:


⚡ nc -lk 0.0.0.0 8888


and I try to connect from another devices (192.***.0.167 is the IP of the Mac Mini) here is what's happening:


daniele@xxxxx /home/daniele

⚡ while true; do sleep 2; nc -zv 192.***.0.167 8888; done

^C


daniele@xxxxx /home/daniele

⚡ nc -zv 192.***.0.167 22

Connection to 192.***.0.167 22 port [tcp/ssh] succeeded!


daniele@xxxxx /home/daniele

⚡ while true; do sleep 2; nc -zv 192.***.0.167 8888; done

Connection to 192.***.0.167 8888 port [tcp/*] succeeded!

Connection to 192.***.0.167 8888 port [tcp/*] succeeded!

Connection to 192.***.0.167 8888 port [tcp/*] succeeded!

^C


[Personal Information Edited by Moderator]



In the first attempt I don't get any answer, so I interrupt after a while; then a connection on the SSH port (remote login is enabled) "unlocks" the other ports, and finally if I try to connect it magically works!

After a while the port becomes unavailable again and to access the service I must first connect to the SSH port.


Could you explain me what's happening?


Thank you


Mac mini, macOS 13.0

Posted on Dec 1, 2022 3:00 AM

Reply
Question marked as Best reply

Posted on Dec 5, 2022 6:52 AM

daniele2010 wrote:

I would never have said that :D
But how is it possible that I can't disable sleep with a GUI? Is it only possible via Terminal?


I don’t have macOS Ventura to check, as was mentioned.


The macOS Monterey image shown above disables sleep.


According to the following doc, it’s possible to do in Ventura:

... Set sleep and wake settings for your Mac - Apple Support

Change Displays settings on Mac - Apple Support



Similar questions

12 replies
Question marked as Best reply

Dec 5, 2022 6:52 AM in response to daniele2010

daniele2010 wrote:

I would never have said that :D
But how is it possible that I can't disable sleep with a GUI? Is it only possible via Terminal?


I don’t have macOS Ventura to check, as was mentioned.


The macOS Monterey image shown above disables sleep.


According to the following doc, it’s possible to do in Ventura:

... Set sleep and wake settings for your Mac - Apple Support

Change Displays settings on Mac - Apple Support



Dec 1, 2022 9:27 AM in response to daniele2010

This desktop Mac (running macOS Monterey) is set to not sleep, using System Preferences:


$ pmset -g
System-wide power settings:
Currently in use:
 Sleep On Power Button 1
 autopoweroff         1
 autopoweroffdelay    28800
 standbydelayhigh     86400
 standbydelaylow      0
 standby              1
 proximitywake        1
 ttyskeepawake        1
 hibernatemode        0
 powernap             0
 gpuswitch            2
 hibernatefile        /var/vm/sleepimage
 highstandbythreshold 50
 displaysleep         30
 womp                 1
 networkoversleep     0
 sleep                0 (sleep prevented by backupd, sharingd, backupd-helper)
 tcpkeepalive         1
 halfdim              1
 autorestart          0
 disksleep            0
$ 


Here is what this setting looks like in System Preferences:


macOS Ventura changed the Settings displays, and I don't have a Ventura system handy to post what that looks like.

Dec 1, 2022 6:14 AM in response to daniele2010

What’s the network topology?


Are you attempting to access 192.168.0.167 via the local host (from .167 to itself), or from another host in the same 192.168.0.0/24 subnet?


Any add-on security services apps, or add-on anti-malware apps, or add-on firewall apps installed on .167? Any add-on VPN client apps involved on .167 or on the host initiating the ssh to .167?


More generally and not directly related to the question, I’d stay out of 192.168.0.0/24 and 192.168.1.0/24 generally, as those private class C subnets are widely used and that tends to get routing tangled which gets VPNs tangled.

Dec 1, 2022 6:28 AM in response to MrHoffman

Hi MrHoffman, thank you for your help.


They are in the same subnet, and I'm trying to access from another host of that subnet (different IP).


I didn't installed anything in particular, I don't know very well softwares on Apple devices in general.


Last, I'm not currently using any of these subnets, I've changed it manually in the post description.


It seems to me that it could be something related to energy saving, but it's very strange.

I thing I could bypass the problem with a loop that connects regularly on ssh port but it would be awkward.

Dec 1, 2022 7:47 AM in response to daniele2010

These are power my management settings, there seems to be no setting related to the problem:


Lock Screen

Start Screen Saver when inactive - For 20 minutes

Turn display off when inactive - For 10 minutes

Require passwords after screen save begins or display is turned off - Immediately


Energy Saver

Put hard disk to sleep when possible - Off

Wake for network access - On

Start up automatically after a power failure - Off


(I've rewrote them manually, the screenshot doesn't seem to work)

Dec 3, 2022 1:59 AM in response to MrHoffman

This is my actual situation:


⚡ pmset -g                  
System-wide power settings:
Currently in use:
 standby              0
 Sleep On Power Button 1
 autorestart          0
 SleepServices        1
 powernap             1
 networkoversleep     0
 disksleep            0
 sleep                1 (sleep prevented by powerd)
 ttyskeepawake        1
 displaysleep         10
 tcpkeepalive         1
 womp                 1


I tried changing powernap to 0 but I didn't notice any improvement.

Exposed port unavailable after a while

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.