I was working on the CSS for my website and accidentally ran it, which opened a JSON file. Now, whenever I try to run any of my HTML files, a new tab is opened that says "unable to connect to local host". I’ve also tried running previous projects and they will not run. I get a message about opening a JSON file instead. Is there a way I can fix this?
I’ve tried reinstalling VS code but that didn’t do anything.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: http
//go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "npm start",
"name": "Run npm start",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
},
{
"name": "Attach to Chrome",
"port": 9222,
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}"
},
]
}
2
Answers
To run an HTML file correctly, you just change this JSON section:
to:
Or you can use a local server like XAMPP to run an HTML file as URL
http://localhost/index.html
In your config,
Launch Chrome
‘s port is configured as 8080 but the debugger attaches to port 9222 as configured inAttach to Chrome
. Maybe this discrepancy is the problem?