by Sai gowtham

How to change a port number in Vue App

In this tutorial, we are going to learn how to change a default port number in vue app which is created using the vue cli.

Changing port number

  1. Open the vue app in your favorite code editor.
  2. Create a new file called vue.config.js in your root directory.
  3. Add the following code, by replacing it with your port number.
vue.config.js
module.exports = {
    devServer: {
        port: 3454    }
}
  1. Now, run the app using npm run serve command, your port number is successfully changed.
 DONE  Compiled successfully in 2114ms


  App running at:
  - Local:   http://localhost:3454/
  - Network: http://192.168.43.18:3454/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

If you want to change the port number temporarily, you can add a --port option to npm run serve command.

Example:

npm run serve -- --port 2345

You can also learn about, how to change a port number in React.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
130,921 students enrolled
21 hours of video content
View Course