Published local port

Can you please explain what this section is for?
Isn’t it enough to connect to a local server with a hostname like localhost?