This probably means it’s some kind of network configuration issue on your end. Either some network restriction or firewall. As for why you can access it via browser, I have an idea.
I believe you’re on a Windows machine correct?
If that is the case then Linux containers use WSL to build and run. For this WSL needs to have the necessary network access. Just because your Windows PC has access doesn’t necessarily mean your WSL has the same access.