38

I created a new site using vue-cli. I'm using the development server to serve the page. When I view the page in my browser, I see two types of errors show up in my browser console:

GET http://172.31.7.153:4000/sockjs-node/info?t=1555922702538 net::ERR_CONNECTION_TIMED_OUT
GET http://localhost:4000/sockjs-node/info?t=1555922708541 net::ERR_CONNECTION_REFUSED

I'm not sure what it means, or how/why it's being called, and it shows up repeatedly about every 5 seconds.

Blaine Lafreniere
  • 3,451
  • 6
  • 33
  • 55

5 Answers5

52

I finally fixed it using the devServer.public configuration option.

Below is my vue.config.js file:

module.exports = {
    devServer: {
        disableHostCheck: true,
        port: 4000,
        public: '0.0.0.0:4000'
    },
    publicPath: "/"
}

I got my answer from reading this.

Blaine Lafreniere
  • 3,451
  • 6
  • 33
  • 55
31

To disable this warning just the config host: 'localhost' is needed.

module.exports = {
  devServer: {
    host: 'localhost',
  },
};

Create this file vue.config.js if not exist at root.

Note: The disableHostCheck config is officially discouraged.

More info:

Nakamoto
  • 1,293
  • 14
  • 17
2

I fixed this with the following vue.config.js file:

module.exports = {
  devServer: {
    host: '0.0.0.0',
    https: false,
    port: 8080,
    public: 'http://0.0.0.0:8080'
  },
}
HyperActive
  • 1,129
  • 12
  • 12
2

For me this worked in vue.config.js:

module.exports = {
    devServer: {
        public: 'localhost'
    },
}

I also tried to use host like Nakamoto suggested but then the site was not loading anymore.

Mano Meter
  • 21
  • 3
0

I know it's a remote case and it does not apply to the OP, yet I bumped into this question and several similar ones after making the silliest mistake: did you turn your Webpack (or other) compiler on?

I wish I had found the hint so I thought I would leave a small life jacket.

[ Background: I missed noticing having forgot to run my npm run serve (it could have been yarn start). At the beginning of my coding session I did not launched Webpack's bash script, so I wasted quite some time trying to figure our what I could have done wrong last night. It had nothing to do with my code. ]

Giampaolo Ferradini
  • 529
  • 1
  • 6
  • 17