Live Server in VS Code

When i try to run a js file in vs code (with live server extension) I get ‘local host: 8080 can’t be found’. I have read various forums trying to deal with this, apparently, common problem, but have not found anything that solves the problem.
Can anyone explain it in simple language and provide a step by step solution, please.
Also, I read somewhere that there is a text editor in freecodecamp. I can only find the editor in the js exercises. I need a clear version so I can see the console. Help needed, again, please.

I would guess that your localhost (as an alias like in /etc/hosts for linux) isn’t pointing to the right IP address.

If you go to live server settings in vscode, you will see the input for the local IP address. In that input add this 127.0.0.1. This means that the server is yourself, and not an external IP address.

Dont worry about the port, they likely just take any port.

Thanks for replying. I am new to all this. Where do I find 'live server settings in vscode?
settings.json reads “liveServer.settings.AdvanceCustomBrowserCmdLine”: “chrome”,
“liveServer.settings.CustomBrowser”: “chrome”

launch.json reads
“type”: “chrome”,
“request”: “launch”,
“name”: “Launch Chrome against localhost”,
“url”: “http://localhost: 8080”,
“webRoot”: “${workspaceFolder}”

Is it one of these I need to change?
I tried changing URL to 127.0.0.1 but it says ‘refuses to connect’.

Just found the live server settings. It is already set at 127.0.0.1

That looks fine to me. I can’t really give you any better advice at the moment. The error isn’t very explanatory either.

you should use the live server to open an html file instead I think

Thanks, Ilenia. Same result, I’m afraid. ‘localhost refused to connect.’

maybe a firewall that’s stopping the connection?

It could also be useful if you include a picture of the bottom left corner of vscode, where live server shows the port where is listening to, and what happens then when you open it in the browser.

Hope that is clear.


I’d keep in my that you could have firewalls issues as well, as another user suggested. But I am not sure this should interfere with a request to yourself.

you could try to follow an article like this

If this is just for testing pure JS I’d suggest Quokka.js (I’d also try Live Preview instead of live server)

1 Like

Thank s I’ll try those

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.