20

I am working on Angular7 with visual studio code editor URL: http://localhost:4200 (Working fine)

But, I installed extension Live Server and when I click on Liveserver icon its giving me the error

"Error on port 5500. Please try to change the port through settings or report on GitHub."

So, I opened the File->preference->Settings->LiveServerConfig and tried to change port in settings.json file

{
    "typescript.tsdk": "./node_modules/typescript/lib",
    "tslint.enable": false,
    "liveServer.settings.multiRootWorkspaceName": "QiwkCollaboratorTool",
    "liveServer.settings.root": 0  // New added line
}

Am I going into right direction or am I missing something ? I am not sure how to change the port number 5500 to 0 as I want random port number.

Thanks in advance!

Swapnil G Thaware
  • 799
  • 3
  • 6
  • 19

3 Answers3

22

I got the answer I was editing the wrong settings.json there were two .json files.

enter image description here

Also, I put the below code:

{
    "liveServer.settings.multiRootWorkspaceName": "",
    "liveServer.settings.port": 0
}

But thanks Danny

Joel Carneiro
  • 3,287
  • 3
  • 16
  • 20
Swapnil G Thaware
  • 799
  • 3
  • 6
  • 19
9

I hope this helps: in the settings.json add the following line.

"liveServer.settings.port": 0,

A value 0 (zero) is used for a random port. Any other numbers is for a fixed port number.

Danny Acosta
  • 129
  • 7
4

Solution

1. First, navigate to Settings (Ctrl+Comma).

First

2. Now click on Extensions, which is located on the left side of the window.

Screenshot

3. After that, scroll down and find a tab by the name of Live Server Config.

4. Click on that, scroll down, now click on Edit in settings.json under Settings: Port.

Screenshot

5. A new window will pop up. Here you go, now you can change the port number.

Screenshot

6. At the end, save the file Ctrl+s.

liveServer.settings.port: Customize Port Number of your Live Server. If you want random port number, set it as 0.