Node Server Running But Localhost Refusing to Connect

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



Leave a reply



Submit