I'm using npm json-server
from here. It used to work great for my needs: run a server on my PC and do GET
requests to local IP (192.168.1.XX). I reinstalled it and now I can do requests only to localhost or 127.0.0.1. Can't do requests to local IP (cmd ipconfig) anymore. I'm getting this error:
As @fvu mentioned here
this means that the server software is configured to listen on the localhost interface only. This is a configuration item and to avoid exposing a potentially unsecure server many server programs come preconfigured to listen on localhost only.
So is there a way to access this server via local IP as long as json-server doesn't have some extra parameters to enable/disable it?
I found the solution for this issue:
Using this command, server is deployed on my local IP, and Windows asks for a firewall exception.
Another solution is to switch to .NET server - another free simple fake server where I can setup local IP as endpoint.
All it needs to:
use CMD commands:
Here's another method that worked for me. If you start json-server using your local LAN IP (e.g. 192.168.1.45), you can access the server using an IP address (but not localhost for some reason). For example...
Hope that helps!
Another option that worked for me:
Note: You need to enable port 3000 for TCP/UDP through firewall though. Something like this
Localhost if you will use the same device:
the localhost IP is 127.0.0.1 so, you can access this filename.json by 2 ways, either by
In case you want to access the localhost from another computer/mobile device, place the IPV4 address of your computer
You can also assign a port number of your own using this command:
then run it on any device connected with the same network using
Finally if you did not understood where did i take this host IP from, Go to command prompt > config /all and look for IPv4 address, copy paste that address to this URL, remember that devices should be on the same network to access this IP.