If I understand correctly, you can connect to the localhost on your Windows machine. This means everything is working.
Yes, server is Windows, the client is also the Windows. It means server on Windows is good.
But you cannot connect to the localhost on your Ubuntu machine.
No, the server is Linux, the client is Linux too. It also cannot connected by Windows client. Which means the server on Linux is not working.
I have figured it out. It was the firewall. After run cmd “ufw allow 4000”, everything goes well. Thanks.