The scenario

You’ve added ‘mynasbox¬† 192.168.1.50’ to your hosts file, you want to be able to type mynasbox in the Firefox URL bar and get to its web-based config UI, but instead you’re seeing a ‘There seems to be a problem with this URL’ error message.

tl;dr

In Firefox about:config, set browser.fixup.dns_first_for_single_words to true to be able to use single-word domain name mappings in your hosts file at the same time as retaining the ability to type searches in the Firefox URL bar.

The Full Story

This topic usually goes off the rails when discussed on ‘net forums because Firefox does not in and of itself directly read your hosts file – it relies upon the operating system to resolve domain names for it. In practice though, things are far from that simple; Firefox has had quite a few features added over the years to assist users in getting to web sites even if they don’t type in a proper domain name, which can mean that what you typed gets invisibly altered before any DNS query takes place, confounding the more technical among us.

There are two features of Firefox config that are at play here – keyword and fixup. Both are accessed by browsing to about:config and accepting the dire warning, then typing the feature name in the search box. The keyword feature seems rather unpopular these days (go search if you’re interested in what it’s for), and though you can achieve the desired result by setting this to false, if you do so you also lose the ability to type searches in the Firefox URL bar. Consequently it’s best to leave this at its default value of true (and indeed this must be the case for the fix below to work correctly).

fixup is the feature where Firefox will try to turn what you type into a parseable URL. It is this that causes the eventual DNS lookup not to match your hosts file entries. Feel free to play with the set of browser.fixup options available, however I find that setting browser.fixup.dns_first_for_single_words to true is the simplest general fix for the problem statement, on the basis that all my local servers have one-word names in the hosts file.

References

https://superuser.com/questions/382905/how-to-prevent-firefox-converting-localhost-urls-into-search-queries

https://support.mozilla.org/en-US/questions/1117449

https://support.mozilla.org/en-US/questions/1011327