Skip to content

Webpack dev server with Vagrant forwarded port #3361

Closed

Description

@elclanrs

macOS El Capitan
angular-cli: 1.0.0-beta.21
node: 6.9.1
os: darwin x64

I'm running ng serve within a Vagrant box. I configured Nginx following these instructions. Everything works as expected when I forward port 4200 in Vagrant, but it fails with any other port, with this error:

[WDS] Disconnected!
GET http://localhost:4200/sockjs-node/info?t=1480728685812 net::ERR_CONNECTION_REFUSED

I understand why this happens, it's because in the guest I reverse proxy port 4200 to port 80 which is exposed as port 1234 in the host, like:

config.vm.network 'forwarded_port', guest: 80, host: 1234

In order to get it working I need the following:

GET http://localhost:1234/sockjs-node/info?t=1480728685812

I found out the code that handles this in server-webpack.ts, line 38:

`webpack-dev-server/client?http://${serveTaskOptions.host}:${serveTaskOptions.port}/`

I need to hardcode serveTaskOptions.port to 1234 make it work.

I think Webpack's --public option may help, but it is not exposed to ng serve. Any ideas how to get this working without the hack? Perhaps exposing a different port option for port forwarding, since the guest port where webpack is running may not be the same port in the host?

Activity

  1. changed the title [-]Expose webpack's --public option to ng serve[/-] [+]Webpack dev server error with Vagrant forwarded port[/+] on Dec 3, 2016
  2. changed the title [-]Webpack dev server error with Vagrant forwarded port[/-] [+]Webpack dev server with Vagrant forwarded port[/+] on Dec 3, 2016
  3. added a commit that references this issue on Apr 12, 2017
    9a0eaf9
  4. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 6, 2019
  6. added a commit that references this issue on May 29, 2026
    3044801
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions