Fixes bug where port was not set correctly when changing environments