"localhost refused to connect" vscode html - html

<!DOCTYPE html>
<html>
<head></head>
<body>
<button>Hello</button>
</body>
</html>
Running this code from VSCode on my M1 Air yields either this:
..or a completely blank page.
What am I doing wrong? Was working, but then I accidentally clicked "run" on a .css file instead of my .html file, and it broke.

You can just open your .html file by double-clicking on it from your file browser.
Or if you want to serve it locally, you can use an extension like Live server. And then from your Editor, you can click on "Go Live"
Then this would show that your local server is running on a port like here it's 5500
Then the extension should open a new tab in your browser to http://127.0.0.1:5500/FILENAME.html.
If you don't want to use this VS Code extension, you can try other alternatives like browsersync.

localhost refused to connect.
is an error message that typically appears when there is a problem with the connection between Visual Studio Code (VSCode) and the localhost server. This can happen for a number of reasons, but some common causes include:
The localhost server is not running or is not configured properly.
There is a problem with the network connection, such as a firewall blocking the connection.
There is an issue with the code or configuration of the HTML file in VSCode.
To troubleshoot this issue, you can try the following steps:
Check that the localhost server is running and configured correctly.
Check your network connection and ensure that any firewalls or antivirus software are not blocking the connection.
Check your HTML code and configuration in VSCode to ensure that there are no syntax errors or other issues that might be causing the problem.
Make sure that the chrome browser is in the updated version.
Check the port number if it is configured correctly in your code, if not change it to the correct port number.
Open your .html file by double-clicking on it from your file browser or right click context menu and then open with option, choose a browser option.
Use Live Server VS Code Extension or BrowserSync Extenstion.
If the problem persists, you can also try running the HTML file in a different browser or using a different localhost server to see if that resolves the issue.

Related

vs code live server extension not working

I'm trying to run a basic html file with live server extension, when I run it I get the Server is Started notification(as shown in the img below) but then nothing happens
even manually going to port 5500 like "http://127.0.0.1:5500/index.html" I get the following error
Cannot GET /index.html
i tried restarting vs code. uninstalling and reinstalling live server extension also tried uninstalling and reinstalling vs code. i set the default browser in the extension settings and on my computer any other ideas i can try would be appreciated
Thank you
I'm not sure why but changing file names (removed special characters) worked only if i do it manually it still doesn't load the browser automatically though..
This could be the issue I just solved.
VS code was not using the local IP as a host.
Manage > settings > search "use local" or "live server"> check "use local IP as host".
I hope that helps you or your connection needs could be unique and you might want to look at this guide. https://code.visualstudio.com/docs/setup/network

Live Server Extension gets stuck iterating through port values every time I "Open with live server" from my html file

My file name is index.html
I have tried running the command and manually entering http://127.0.0.1:5500/index.html into the browser this also does not work. I get a refused to connect message.
I have ensured I have a default browser set.
I have tried just about everything.
As soon as I select "Open with live server" VS Code starts processing the request, I navigate to settings.json where the extensions settings reside.
All I have in my settings.json is
"liveserver.settings.port": 5500
and in real time the file starts increasing the port number by 1 about every second. I have to physically close VS Code to stop it. "Stop live server" does not work.
I have tried uninstalling the extension, older versions, and even completely uninstalling VS Code.
NOTHING is working.
Please send help.
Try the steps from this question:
Live server installed but not working in VS code

Not allowed to load local resource in console for using live server at vs studio

I've tried by changing the IP address and also changed the default browser, but still not working.
Check if you have written a nasty code which blocks some of the function of live server. Just go on element tab in dev tools and scroll down to check the script written after <-- Code Injected by Live Server -->.
See whether you have used the same name for any function in your any js file. If so just change their names. If this does not work then try to reinstall live server extension.

VS Code 2017 "Localhost refused to connect" HTML file

This is a simple index.Html file, when i click on run i get the attached screen.
I have included the Json configuration.
The previous posts did not resolve my issue, and i did restart the machine as well as running VS Code as an admin. VS Code Error
installed Extensions
This happening because of your firewall setting restriction. please
Try Live Server Extension AND check for Firewall Settings.
Plain HTML/CSS can be opened as a file, no need to run them through a web server.
And if these procedures didn't work tell me about your browser.

How to open a HTML file on remote machine on local browser

I have written a simple HTML file on an EC2 instance. I want to check if it functions as desired. Is there a way I can open it on my local browser for testing?
EDIT: The output depends on some configurations which are present only on the remote machine!
You will need to install and start apache, placing the HTML vile in the www directory on the sever. Then open port 80 in your ec2 security group, but specify this rule to only be for the public IP of your home machine.
If its a HTML file you can open it directly from your desktop but if is a php file you need local server such as Xampp or wamp. If you want to edit it you can have a code editor such as notepad++ ect.. Hope this helps
If I understand you correctly. .. just open the file. It will run in your browser. It is just text. It is your browser that runs it.