It is assigned by a regexp that strips the port from the URL in the ns_conn structure's location field.
What version of OpenACS are you running?