Unable to install using a non-standard port

I am unable to install when using a URL like http://localhost:8080/setup
It redirects to http://localhost/setup

I presume the core assumes port 80

Any fix for this?

I don’t think it does. I use http://localhost:8080/ all the time to install MODx and never had a problem.

It absolutley does:

david@david-wakelin-desktop:/tmp$ wget http://localhost:8080/setup
--2021-06-08 10:41:11--  http://localhost:8080/setup
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/setup/ [following]
--2021-06-08 10:41:11--  http://localhost/setup/
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.

This is using a fresh copy of 3.x-dev installed via composer: composer create-project modx/revolution modx-test 3.x-dev

In fact I can see on line 25 of setup/privisioner/bootstrap.php it removes the port if not 80:

if (isset($_SERVER['SERVER_PORT']) && (string)$_SERVER['SERVER_PORT'] !== '' && $_SERVER['SERVER_PORT'] !== 80) {
    $installBaseUrl = str_replace(':' . $_SERVER['SERVER_PORT'], '', $installBaseUrl);
}

And the next line should then put the port back in.

So it seems $https is somehow true or on in your case.

OK, my fault. Had a problem in my Nginx config.