Firefox: No connection to localhost domains when offline

After upgrading from Ubuntu 14.04 to Ubuntu 16.04, I was not able to connect to domains pointing to 127.0.0.1 when I had no network connection - in Firefox. In Chrome, it worked correctly.

As a web developer, I have a bunch of projects running on my laptop with domain names defined in /etc/hosts that point to the local machine, 127.0.0.1. On the train I have no internet connection but still want to work on my projects, so it's crucial to be able to access them.

Symptom

When accessing http://www.bogo/ that has an entry in /etc/hosts, Firefox showed an error page:

Seite wurde nicht gefunden

Die Verbindung mit dem Server www.bogo.com schlug fehl.
Falls die Adresse korrekt ist, können Sie noch Folgendes versuchen:

  • Die Seite später noch einmal aufrufen.
  • Die Netzwerkverbindung überprüfen.
  • Falls der Computer sich hinter einer Firewall befindet, überprüfen Sie bitte, ob Firefox der Internetzugriff erlaubt wurde.

In english:

Hmm. We’re having trouble finding that site.

We can’t connect to the server at www.bogo.com.
If that address is correct, here are three other things you can try:

  • Try again later.
  • Check your network connection.
  • If you are connected but behind a firewall, check that Firefox has permission to access the Web.

Solution

I found question that had the correct solution for me:

  1. Open about:config
  2. Search for network.dns.disableIPv6
  3. Set it to false

After that it worked for me.

Firefox bug 1267257 seems to be describing this issue.

Written by Christian Weiske.

Comments? Please send an e-mail.