Fix port 0 bug in URIPORT

Fixes #4164.