#Can't connect to the localhost vite server from Firefox on Windows 10

1 messages · Page 1 of 1 (latest)

neat anvil
#

I just scaffolded a new vite app using npm init vite and chose the options to create a Svelte + typescript app.

After running npm install and npm run dev vite starts up a dev server on 5173. I can't connect to this server from Firefox, it just gives me the "Unable to connect" page.

I can connect to it fine from Chrome. So I thought, maybe Firefox has a problem with localhost connections or something. I spun up a freshly scaffolded create-react-app and Firefox connects to that just fine.

I tested a couple other web servers, Firefox can connect to all of them.

I also tried running the build and starting the preview server, but again Chrome can connect, Firefox can't. I also tried configuring the vite server to listen on port 80, but just get the same behavior.

Any idea why Firefox won't connect to the vite server?

rancid glacier
neat anvil
#

Hmm interesting... [::1] works. Weird. Why would IPv4 vs IPv6 makes a difference? And why only with the vite server?

#

So neither localhost nor 127.0.0.1 were working. It turns out, a long time ago I enabled an option in about:config called network.dns.disableIPv6 to workaround some other problem I was having with some websites.

#

If I reset that option, localhost works again, but 127.0.0.1 doesn't. So I guess the vite server doesn't bind on any ipv4 addresses?

#

That's definitely it. The create-react-app server doesn't bind on ipv6 addresses by default. Thanks for the help!

rancid glacier
#

The Vite dev server binds to localhost by default. On node >=17, this refers to whatever your OS points to e.g. either 127.0.0.1 or [::1] (in your case, the latter). Lower node versions, always use 127.0.0.1.