0

Vue.js Automatically picks up a new port every time a dev build is being created.Whenever i try to run npm run dev it automatically selects a port on its own instead of the one mentioned in config/index.js

port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined

I understand the comment mentioned here,but when i tried to change port in build/webpack.dev.conf.js too

devServer: {
    clientLogLevel: 'warning',
    historyApiFallback: {
      rewrites: [
        { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
      ],
    },
    hot: true,
    contentBase: false, // since we use CopyWebpackPlugin.
    compress: true,
    host: HOST || config.dev.host,
    // port: PORT || config.dev.port,
    port: 8080,
    open: config.dev.autoOpenBrowser,
    overlay: config.dev.errorOverlay
      ? { warnings: false, errors: true }
      : false,
    publicPath: config.dev.assetsPublicPath,
    proxy: config.dev.proxyTable,
    quiet: true, // necessary for FriendlyErrorsPlugin
    watchOptions: {
      poll: config.dev.poll,
    }
  },

seems not to work as well.I want my vue app to be listened on only one port that i mention,any help regarding this issue would be really appreciated.

I already have seen this question but this doesn't solve my problem. Related question

Awais fiaz
  • 351
  • 1
  • 5
  • 20

1 Answers1

2

Vue is picking up a new port automatically, because it finds the current port as busy. You can check if the port is already in use or not, if yes then do the following:

Find if port (here '8080') is in use:

sudo netstat -lpn |grep :'8080'

Kill the process:

kill -9 <PID>
Helping hand
  • 2,800
  • 2
  • 19
  • 31