You should always mention docker when asking questions on this forum. It is quite often the reason for issues and saves everyone some time going down the wrong path.
So, localhost to node-red is not gonna be localhost to mosquito. Node-reds localhost will be its own container (not where mosquito is running)
Is mosquito installed directly on the computer or in another docker container?
Either way, you will likely need to access mosquito via ip address AND since it is ver2 you will need to modify its config to permit external connection.
Ps, out of curiosity, why are you using docker? If you are not familiar with docker networking and volume persistence etc this can be more effort than it is worth.