strip old port value before appending new
(cherry picked from commit 5786177)