node server running but localhost refusing to connect
I suspect you are on a Mac. First change 192.168.1.2
to 127.0.0.1
, or 0.0.0.0
if you want to be accessible from other computers.
Next browse to http://127.0.0.1:1337/, not http://localhost:1337/. For whatever reason localhost
resolves to ::1
- an IPv6 address on my Mac. For some reason Node immediately disconnects any IPv6 connections on my machine.
Node.js localhost:3000 refuses to connect
Here is how to fix it. Your probably try to launch your server on a used port.
// enter this command in your terminal
lsof -i:3000
// this will output the related PID (process ID). Here: 1382.
node 1382 name 21u IPv6 blabla 0t0 TCP *:3000 (LISTEN)
// kill the PID in use
kill -9 1382
//relaunch your server
node app.js
Connection refused on localhost
Try changing the url from localhost to 127.0.0.1 . If it works, then it means your environment is not resolving localhost to 127.0.0.1
Or Try with changing the PORT Number
Node.JS: Why is my connection to localhost:3000 refused?
In following the instructions to set up the server on the command line, install the dependencies, and navigate to localhost:3000
It seems that you didn't start the server.
Somewhere between installing the dependencies and navigating to the URL you need to actually start the server if you want it to serve the request.
express.js - server listening but localhost refused to connect
You mentioned https://localhost/3000
. One problem is that it should be https://localhost:3000
(:
instead of /
), and another one is that you probably mean to use http
on localhost. Try: http://localhost:3000
Related Topics
Invalid Attempt to Spread Non-Iterable Instance
How to Get Route Url Params in a Page in Nuxt2 and 3
Jquery Change Event Called Two Times
Generate and Download CSV File With PHP and Ajax
Modifying a Query String Without Reloading the Page
Deselect All Options in Multiple Select With 1 Option
The Onclick Is Not Working on First Click
Onclick Event Function in JavaScript
Will a React Component Re-Render If Its Props Are Updated, But Don't Change in Value
How to Place Button on Right Side in Reactjs
Passing Data from Node Js to HTML Using Ejs
How to Change Background Color of a Row on Checkbox Selection
Starting the Week on Monday With Isoweekday()
Detect If Page Is Load from Back Button
Fix: Js Recursive Function to Get the Nested (Multilevel) Child Objects as Array of Objects
Javascript/Dom: How to Remove All Event Listeners of a Dom Object
Bootstrap Datepicker Appearing At Incorrect Location in a Modal