I need to change the port OctoPrint is listening on on OctoPi because I want to do a port forward and that port is already used in my router!

A proper router should actually allow you to create a port forward that forwards to your internal host "hostA" and port "x" from external port "y": route:y->hostA:x. So something like router:9080->octoprint:80 should be possible. Same goes for a scenario where you do something like router:9080->octopi1:80, router:9081->octopi2:80, etc.

These are standard network administration tasks your router should allow you to do. If it doesn't, it doesn't justify being called a router and you should complain to the manufacturer. OctoPrint and OctoPi are not a replacement for a proper network infrastructure.

That being said: Using OctoPi you are accessing OctoPrint on port 80 or 443 through haproxy, so you need to change the port number of that instead of the port number OctoPrint itself is listening on (which is port 5000 on localhost only). You'll need to edit /etc/haproxy/haproxy.cfg for that. There are lines that look like this:

frontend public
        bind *:80
        bind 0.0.0.0:443 ssl crt /etc/ssl/snakeoil.pem

You'll need to change the 80 in bind *:80 if you want to change the http port, and the 443 in bind 0.0.0.0:443 ssl crt /etc/ssl/snakeoil.pem if you want to change the https port.

:warning: Warning

Do not set haproxy to listen on port 8080. That is what the bundled webcam server is already listening on. If you configure it to use port 8080 it won't start.

After a reboot, haproxy should then listen on the new port. Note that that means it will ONLY listen on those ports - you'll need to provide the new port when accessing your OctoPi instance from inside of your network now!

A post was split to a new topic: Changing my port broke authentication and now I can't connect

A post was split to a new topic: Changing haproxy's port broke something, my Pi won't boot