[Vuejs]-Vue.js webapp not accessible under localhost:<port>

3👍

Right after asking the question, I found a similar one here for everyone that has a similar issue.

To summarize the solution for me was to add –host 0.0.0.0 to the npm run serve command in the package.json so that the line looks like this:

"scripts": {
    "serve": "vue-cli-service serve --host 0.0.0.0",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },

After this the output when running the command changed back to displaying localhost and I can access the page again via localhost:<portnr>.

I can’t see any disadvantage in doing this simple fix. If there is, I will be glad to hear about a better solution!

1👍

I tend to see you have local DNS server setting problem on the pc.

  • Windows

Open %systemroot%\system32\drivers\etc\hosts file with notepad or other editors as administrator.
Maybe the file looks like this:

... ... ...
# localhost name resolution is handled within DNS itself.
#       127.0.0.1       localhost
#       ::1             localhost

You will need to uncomment 2 bottom lines if localhost wasn’t be bound on Windows

  • Unix(Linux/macOS)

Open /etc/hosts file with nano or other editors with sudo privilege.

You should get something similar to the below. If not, please make it like this.

##
# Host Database
# ... ... ...

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Leave a comment