"code listen permission denied 127.0.0.1:1807"

I’m getting this error when I try to start PhotoStructure on my Windows desktop PC. I tried manually allowlisting PhotoStructure in the firewall as per the documentation, but the error continues to appear:

Running PhotoStructure as administrator still shows the same error :frowning:

Any ideas?

That firewall config seems reasonable. Your certainly shouldn’t need to run PhotoStructure as an administrator.

Are you on a public or private network?

Private network.

Huh. I’ll check my Windows box.

Are you running any other third-party networking stuff?

I have a bunch of network adapters from various things (VMWare, Hyper-V, Docker, WireGuard) and the network adapter is bridged to a Hyper-V virtual switch. Perhaps one of these is conflicting with it? I’m not entirely sure and it seems weird that that’d cause issues listening on a particular port.

Is there a way to get verbose logs out of PhotoStructure for this error message?

https://photostructure.com/faq/error-reports/#how-to-manually-send-your-logs

But I suspect the logs will just say what the error dialog tells you.

You’re right; it’s basically the same thing in the logs:

{"ts":1609701935484,"l":"error","ctx":"Error","msg":"onError(): Error: code EACCES: listen EACCES: permission denied 127.0.0.1:1807\nError: listen EACCES: permission denied 127.0.0.1:1807\n    at Server.setupListenHandle [as _listen2] (net.js:1289:21)\n    at listenInCluster (net.js:1354:12)\n    at doListen (net.js:1493:7)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)","meta":{"event":"fatal","message":"createServer¹"}}
{"ts":1609701935485,"l":"info","ctx":"Service(main)","msg":"exit()","meta":{"status":12,"reason":"createServer¹: Error: code EACCES: listen EACCES: permission denied 127.0.0.1:1807","ending":false}}
{"ts":1609701935487,"l":"error","ctx":"Desktop","msg":"onError()","meta":"createServer¹: Error: code EACCES: listen EACCES: permission denied 127.0.0.1:1807"}
{"ts":1609701935490,"l":"debug","ctx":"Error","msg":"isIgnorableError","meta":{"result":false,"err":"Error: code EACCES: listen EACCES: permission denied 127.0.0.1:1807","ending":false,"isPleaseSend":false,"isFatal":false,"matchesIgnorable":false}}
{"ts":1609701935494,"l":"error","ctx":"Desktop","msg":"onError()"}

I don’t see any other apps listening on port 1807:

PS C:\Users\Daniel> Get-NetTCPConnection -LocalPort 1807
Get-NetTCPConnection : No MSFT_NetTCPConnection objects found with property 'LocalPort' equal to '1807'.  Verify the
value of the property and retry.
At line:1 char:1
+ Get-NetTCPConnection -LocalPort 1807
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (1807:UInt16) [Get-NetTCPConnection], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_LocalPort,Get-NetTCPConnection

Hey, I think I found the problem.

It took a bit of digging but I found this post on SuperUser:

where the commenter said:

In my case the error appears because the port used belong to reserved ports for Hyper-V.

This port range changes when I restart my computer, so sometimes I get the error sometimes no.
To check reserved ports by windows you can use(cmd/powershell):

netsh interface ipv4 show excludedportrange protocol=tcp

The issue is described in: Too many reserved port for Hyper-V · Issue #5514 · microsoft/WSL · GitHub

The port 1807 ended up being in a “reserved port range” for Hyper-V (on my system, 1741-1840 was reserved)

netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
...
      1741        1840

I changed the reserved port range as per the workaround in Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges · Issue #3171 · docker/for-win · GitHub

netsh int ipv4 set dynamic tcp start=49152 num=16384

and rebooted.

It looks like this was sufficient to fix the issue.

I’m amazed that Hyper-V would just hold on to such low port numbers for itself.

1 Like

Wow! Nice sleuthing! :star::star::star::star::star:

I wonder how many other people will bang their head against this? Should I change the default ports to be a bit bigger?

As far as I can tell, Hyper-V seems to pick random port ranges, so changing the port might not help. Might be a good idea to add something to the documentation about it, though?

1 Like