MB-7269: catch exception when using wrong port number

Change-Id: I6987b856329ed918e3e568a4e97340b3ee58729e