Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev server host 0.0.0.0 not available with Docker (Windows WSL) #12995

Closed
Hemric opened this issue Dec 10, 2021 · 4 comments
Closed

dev server host 0.0.0.0 not available with Docker (Windows WSL) #12995

Hemric opened this issue Dec 10, 2021 · 4 comments
Labels

Comments

@Hemric
Copy link

Hemric commented Dec 10, 2021

Environment

Operating System: Windows 10 / WSL 2 - Ubuntu 20.04
Node Version: v16.13.0
Nuxt Version: 3.0.0-27296172.f5307f9
Package Manager: yarn@1.22.15
Bundler: Vite
User Config: css, vite, typescript
Runtime Modules: -
Build Modules: -

Reproduction

npx nuxi init nuxt3-app
cd nuxt3-app
yarn install
yarn dev --port 4000 --host 0.0.0.0
docker run --add-host=host.docker.internal:host-gateway curlimages/curl:latest host.docker.internal:4000

Bug

I'm trying to start the dev server with nuxi dev --port 4000 --host 0.0.0.0 to have a docker container accessing it.
I'm supposed to get the page content, i get a network error instead. This bug only occurs in windows wsl not with linux

Additional context

I need this to work for our local dev environment that includes several nuxt app behind a nginx reverse proxy using https in a docker container.
On linux it's working properly but not with windows wsl 2.
It worked with webpack dev server in nuxt 2.

Logs

curl: (7) Failed to connect to host.docker.internal port 4000 after 2024 ms: Connection refused

@Hemric Hemric changed the title dev server host 0.0.0.0 not available with Docker with Windows WSL dev server host 0.0.0.0 not available with Docker (Windows WSL) Dec 10, 2021
@peteromano
Copy link

This isn't a nuxt issue. docker run here needs --network=host, but it's usually bad practice to use the host network. Why not put Nuxt in a container as well, and have 2 containers using the docker bridge network (or even better, their own network)?

@Louis-Tian
Copy link

This is somewhat related to Nuxt issue. Perhaps not a bug but likely to do with how vite handles connections.
--network=host is not available for Docker for Windows and that's why host.docker.internal is needed to communicate with the host network.
I am migrating from Nuxt2. I have the Nuxt 3 and express api server running on different ports and an Nginx reverse proxy running in docker for CORS.
I can reach the API just fine from within the nginx container but got a connection refused from Nuxt server. At the same time, the Nuxt works perfectly from host directly.

@Louis-Tian
Copy link

@Hemric Did you figure out this one? Appreciate any pointer.

@Louis-Tian
Copy link

Found the root cause. A bug in nuxi dev that caused server only binds to localhost regardless of the host value.
unjs/listhen#19

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants