Results 2 comments of

Same issue with both connected to the same Wi-Fi, PC can send files to Android, but not the reverse. Port number in the error message on the phone changes on...

I fixed it after modifying some firewall settings on Windows. I don't remember what I did, but it probably is the same as what @RobotDodo did above.