Closed Bug 1267257 Opened 8 years ago Closed 11 months ago

Consider checking /etc/hosts if getaddrinfo fails (Local site (not localhost) isn't loaded in Firefox without being connected to the network)

Categories

(Core :: Networking: DNS, defect, P3)

45 Branch
x86_64
Linux
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: vitaly.khatlamadzhiyan+mozilla, Unassigned)

Details

(Whiteboard: [necko-backlog])

Attachments

(4 files)

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160304160129

Steps to reproduce:

Initial data:
 - configured nginx + php-fpm (didn't try with apache, used to nginx)
 - access to the local site via alias (such as http://domain.tld/)
 - there is a line in the hosts that the domain must refer to 127.0.0.1
 - used only local content - without any external resources



Actual results:

Everything works fine, if there is a connection to the network. If it's disconnected, the site becomes unavailable. Firebug says that connection is Aborted - no error codes (code 0). But if I open that site in Google Chrome, there is no problem, everything works.

Proxy - by default.



Expected results:

Question: Why in Firefox, when I open the local, but not http://localhost site without connecting to the network, connection is aborted?

OS: LinuxMint 17.3 x64
Doesn't depend of FF version. I always use latest versions.
Component: Untriaged → Networking
OS: Unspecified → Linux
Product: Firefox → Core
Hardware: Unspecified → x86_64
This sounds similar to bug 956267.
I have try to reproduce this but for me it works fine (I am on ubuntu).
Can you make a http log:
https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging
Flags: needinfo?(vitaly)
Attached file log.txt
Attached file log.txt.child-1
(In reply to Dragana Damjanovic [:dragana] from comment #2)
> I have try to reproduce this but for me it works fine (I am on ubuntu).
> Can you make a http log:
> https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging

Sure. I attached them. Two files were created: log.txt and log.txt-child-1.
Hope, it'll help.
(In reply to Vitaly from comment #5)
> (In reply to Dragana Damjanovic [:dragana] from comment #2)
> > I have try to reproduce this but for me it works fine (I am on ubuntu).
> > Can you make a http log:
> > https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging
> 
> Sure. I attached them. Two files were created: log.txt and log.txt-child-1.
> Hope, it'll help.

Thank you for the log.
It looks like getaddrinfo is not resolving addresses. (I am not sure with one is local ok.ru or www.semeinye-recepti.ru)
but all fail.

2016-05-02 20:33:46.328070 UTC - [0x7fe37227e6a0]: D/nsHostResolver DNS lookup thread - Calling getaddrinfo for host [www.semeinye-recepti.ru].
...
2016-05-02 20:33:46.328178 UTC - [0x7fe37227e6a0]: D/nsHostResolver DNS lookup thread - lookup completed for host [www.semeinye-recepti.ru]: failure: unknown host.

This logs are:
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/nsHostResolver.cpp#1392
and 
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/nsHostResolver.cpp#1438

To be 100% sure i could try to add some logging in nspr (there is no logging hostResolver part of nspr).
I named local site "semeinye-recepti.ru" (without "www"). As I understand, FF redirects to www.domain.tld. Why? I open this site without "www".
Later, I'll add a new record to hosts with www.domain.tld and will see the result.
But why it redirects to www sitename?
(In reply to Vitaly from comment #7)
> I named local site "semeinye-recepti.ru" (without "www"). As I understand,
> FF redirects to www.domain.tld. Why? I open this site without "www".
> Later, I'll add a new record to hosts with www.domain.tld and will see the
> result.
> But why it redirects to www sitename?

May I ask you to try one thing: go to about:config and search for browser.fixup.alternate.prefix. Probably it was value "www." Delete that, leave it empty and try again.
Thanks.
I will work with report to try to figure out what is happening.
This is probably duo of bug 956267 and I expect that changing the pref in comment 8 will solve the problem (at least in  956267 it did)
Assignee: nobody → dd.mozilla
Whiteboard: [necko-active]
Thanks. I can only check this evening.
Attached file log-20160504-1.txt
Without network connection
Attached file log-20160504-2.txt
With network connection
"browser.fixup.alternate.prefix" was "www.".
I cleaned this option, but nothing changed.
I attached two logs: log-20160504-1.txt (without network connection) and log-20160504-2.txt (with network connection).

In hosts have already been two lines:
127.0.0.1   domain.tld
127.0.0.1   www.domain.tld
(In reply to Vitaly from comment #13)
> "browser.fixup.alternate.prefix" was "www.".
> I cleaned this option, but nothing changed.
> I attached two logs: log-20160504-1.txt (without network connection) and
> log-20160504-2.txt (with network connection).
> 
> In hosts have already been two lines:
> 127.0.0.1   domain.tld
> 127.0.0.1   www.domain.tld

I manage to reproduce this on my ubuntu (I had some problems with network and the behavior showed up).

So if Ubuntu has wireless network turned on, but it cannot connect because there is some problem with the network, Firefox cannot connect to the localhost with alias example.com. If I disable network in Ubuntu everything works fine.

I have added some logging and also changed to call getaddrinfo directly (I have replaced our GETADDRINFO def - just to be sure). getaddrinfo returns an error. 

So we cannot do anything about this it is a kernel problem :(
Flags: needinfo?(vitaly)
Closing because this is a problem in getaddrinfo(). :(
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
(In reply to Dragana Damjanovic [:dragana] from comment #14)
> I manage to reproduce this on my ubuntu (I had some problems with network
> and the behavior showed up).
> 
> So if Ubuntu has wireless network turned on, but it cannot connect because
> there is some problem with the network, Firefox cannot connect to the
> localhost with alias example.com. If I disable network in Ubuntu everything
> works fine.
> 
> I have added some logging and also changed to call getaddrinfo directly (I
> have replaced our GETADDRINFO def - just to be sure). getaddrinfo returns an
> error. 
> 
> So we cannot do anything about this it is a kernel problem :(

Does getaddrinfo use /etc/hosts?
If no, you may additional check /etc/hosts after an error from getaddrinfo.
If yes, but how it is realized in Google Chrome? As I mentioned in description, I don't get such error in it.
(In reply to Vitaly from comment #16)
> (In reply to Dragana Damjanovic [:dragana] from comment #14)
> > I manage to reproduce this on my ubuntu (I had some problems with network
> > and the behavior showed up).
> > 
> > So if Ubuntu has wireless network turned on, but it cannot connect because
> > there is some problem with the network, Firefox cannot connect to the
> > localhost with alias example.com. If I disable network in Ubuntu everything
> > works fine.
> > 
> > I have added some logging and also changed to call getaddrinfo directly (I
> > have replaced our GETADDRINFO def - just to be sure). getaddrinfo returns an
> > error. 
> > 
> > So we cannot do anything about this it is a kernel problem :(
> 
> Does getaddrinfo use /etc/hosts?
> If no, you may additional check /etc/hosts after an error from getaddrinfo.
> If yes, but how it is realized in Google Chrome? As I mentioned in
> description, I don't get such error in it.

I am not sure whether getaddrinfo is checking /etc/hosts.
If i remember correctly Chrome does not use native getaddrinfo, they have teir own implementation, therefore it does not have the same problem.

We could consider checking /etc/hosts.
I will change the bug title.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Summary: Local site (not localhost) isn't loaded in Firefox without being connected to the network → Consider checking /etc/hosts if getaddrinfo fails (Local site (not localhost) isn't loaded in Firefox without being connected to the network)
Whiteboard: [necko-active] → [necko-backlog]
Component: Networking → Networking: DNS
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Assignee: dd.mozilla → nobody
(In reply to Vitaly from comment #0)

I have the exact same problem.
It turns out that setting "network.dns.disableIPv6" to "false" in about:config fixes this problem.

With IPv6 enabled, I can connect to 127.0.0.1-domains in /etc/hosts when not connected to any network.
Severity: normal → S3

This seems to work for me in the latest Ubuntu 23.04
If anyone is still seeing this issue please reopen and let me know in what circumstances. Thanks!

Status: REOPENED → RESOLVED
Closed: 8 years ago11 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: