Reputation: 2809
I made a demo app using ExpressJS.
Accessing API through POSTMAN in the system works fine. But I can not access the same with my mobile browser, where both Mobile and Server system are connected to same wifi.
My server.js code:
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.listen(3000, "0.0.0.0", function() {
console.log("Listening on Port 3000");
});
app.get('/server/identify', function(req, res) {
console.log(req.body);
var data = {
"meta": {
"status": "success",
"message": "Server is running"
}
};
res.json(data);
});
Upvotes: 1
Views: 3673
Reputation: 2809
The steps I followed to resolve this: (Thanks to @Elliot Blackburn)
Windows Firewall > Advanced Settings > Inbound rules > New Rule >
Port > Provide port number (in my case 3000) > Select "Allow the Connection" >
Select all (Domain, private and public) > Provide Name and Description > FINISH
(In command prompt)
>> node server.js
Server running in port 3000
[Optional] With ngrok.exe (no need to install)
(In command prompt)
>> node server.js
Server running in port 3000
>> ngrok http 3000
ngrok by @inconshreveable
Session Status online
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://92a8b6b1.ngrok.io -> localhost:3000
Forwarding https://92a8b6b1.ngrok.io -> localhost:3000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
Upvotes: 1
Reputation: 4164
You will need to expose port 3000 on your local network and then access the machine using it's local network IP address. No one will be able to access it unless the port is open on your machine.
Take a look at something like ngrok, this should handle exposing a port for you and make it accessible to anyone you give the link as long as they're connected to the internet. This might help you build your application and test it quickly on your machine and mobile before deploying it.
Upvotes: 2