Hi,
You only need to put the port number in the Service field, not port:5151. I'm guessing that the tool doesn't know what "port" is, so it ignores it and just uses the default service port value. In your case, the connection works because your service is using the default value. I bet that if your port was actually 30000, the connection would fail from the Database Connections dialog box.
The Geodatabase Connection Properties dialog box must pass the literal value for the service, causing it to fail if the value is incorrect.
Try just 5151 in the Service field on the Database Connections dialog box and see if that fixes the problem when choosing versions from the Geodatabase Connection Properties dialog box.
Regards,
Kim