Firefox tries to be too clever and when the address doesn’t work, it tries to connect to sites on common patterns like adding .com or www. to the address in case the user accidentally forgot to put them in.
For web development this can be quite annoying because of testing locally running websites which may or may not be working.
To stop this go type in about:config in the address bar. A warning may appear but acknowledge it.
Filter the config to browser.fixup.alternate.enabled and change the value from true to false. This can be done by double clicking on the row to toggle between the values.
There is no need to save it because the changes take effect instantly.
Disable Firefox redirecting to localhost.com