Fix bug in hosting port determination.

Change-Id: I606aa59669c15cdbdfb0536ca5852dbeeeccc531