Rework hosting port allocation to fix bug.

Change-Id: Ie44e631cbbff4b1a53956ec1a9435ab179e94999