简体   繁体   中英

Unable to access node server created on windows machine on other devices

I am building a web app using Node and express. On my PC, I run the app by typing node app.js which gets the server running on http://localhost:1008/

On my android phone, which is connected to the same network, I typed
http://<ipv4 address>:1008/ but it doesn't work. The wifi network is set to private(home) and i tried turning off firewall, but still it doesn't work
I am using Windows 7 PC.

My app (just a test app)

const express = require('express')
const app = express()

app.set('view engine','ejs')

app.get("/",(req,res)=>{
    res.render('home')
})

app.get("/about",(req,res)=>{
    res.render("about")
})

app.listen(3000,()=>{console.log("server running on port 3000"})

Any help is appreciated

There are several possibilities that you are not able to access your node server on other devices,

  1. You might have installed antivirus on your machine, which is protecting your firewall. So, it is not allowing to access the port on which your application server is running.
  2. Your windows defender is not allowing you to access port outside your host machine.

Solution for above problems is,

  1. If you have antivirus, then you need to allow port from antivirus firewall setting
  2. If port access is denied by windows defender/firewall, then you need to allow port from windows firewall

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM