Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox can't connect to a local site, but Chrome can

I have a web server running locally that's mapped to project.name.localhost:3011 on a MacOSX box. My /etc/hosts defines:

127.0.0.1 project.name.localhost

I need to browse to this server in Chrome and Firefox. Chrome works great when I visit http://project.name.localhost:3011/. Firefox gives an "Unable to connect" connect error. I can see in my local server's console that no connection attempt was even sent to the server when I try from FF.

This is on FF version 59.0.2 (64-bit). FF has no problem with public internet sites like this one, and google.

I've already tried all of the steps suggested here: https://support.mozilla.org/en-US/kb/firefox-cant-load-websites-other-browsers-can In summary, those steps are:

  • Check proxy settings, verify proxy is turned off
  • Set network.dns.disableIPv6 to true in about:config
  • Set network.dns.disablePrefetch to true in about:config
  • Cleared all history, including cookies and cache

Also tried disabling HSTS as described here: https://support.mozilla.org/en-US/questions/1204380

ping project.name.localhost

works just fine also. There is no local DNS issue.

http://127.0.0.1:3011/ gives me the exact same error as using the hostname. However, I need to access the server via a hostname. It is not and should not be configured to respond on a direct IP.

How can I get FF to hit my local web server via a hostname?

EDIT: Two co-workers experienced what they describe as the same problem when they setup their systems, but they both said "it just went away on its own" after a day or two. My problem has persisted across weeks and reboots.


Console output from request:

GET http://global.appen.localhost:3011/invoice_groups

Request headers (398 B) 
Accept  
text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8
Accept-Encoding 
gzip, deflate
Accept-Language 
en-US,en;q=0.5
Cache-Control   
no-cache
Connection  
keep-alive
Host    
global.appen.localhost:3011
Pragma  
no-cache
Upgrade-Insecure-Requests   
1
User-Agent  
Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/59.0

Network Timing:

Blocked:          → 1 ms
DNS resolution:                  → 1 ms
like image 877
Jessa Avatar asked May 04 '18 22:05

Jessa


4 Answers

Edit: Not working [seems internate stops working in firefox with this]

in firefox type about:config

search localhost in it and make below flag true

network.dns.native-is-localhost

Edited

Sorry Its Not reliable solution

like image 161
chintan adatiya Avatar answered Nov 20 '22 06:11

chintan adatiya


You probably just have to clear your FF browser cache. Sometimes you have to clear it all, not just for the site you are working on. Have you done this yet? Old caches can create very mysterious problems like this.

like image 31
mikekehrli Avatar answered Nov 20 '22 05:11

mikekehrli


Firefox gave special treatment to ".localhost" which seems to have caused to problems. When I change my hosts file from project.name.localhost to project.name.devl it started working.

like image 2
Jessa Avatar answered Nov 20 '22 05:11

Jessa


I had an issue with Firefox, where it opened localhost:1234, but couldn't connect and load any resources from static.localhost:1234.

This only happened on sub-domain with a port specified. Thus, static.localhost worked fine.

Adding

127.0.0.1 static.localhost

to hosts file (located in C:\Windows\System32\drivers\etc) solved the problem for me.

like image 2
Tigran Avatar answered Nov 20 '22 06:11

Tigran