node.jsreactjsjson-server

json-server running but can't access its api due to 403


Learning reactjs, trying to simulate a server with json-server
this is my script to run the server:

"scripts": {
    "server": "json-server --watch db.json --port 5000"
},

running this on terminal npm run server
output:

Debugger listening on ws://127.0.0.1:61616/507f7893-92a9-4526-b8f4-a3e71cfa4c62
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

> my-app@0.1.0 server
> json-server --watch db.json --port 5000

Debugger listening on ws://127.0.0.1:61629/8a2f877f-f4bd-465e-b454-01a63eabb40a
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

  \{^_^}/ hi!

  Loading db.json
  Done

  Resources
  http://localhost:5000/tasks

  Home
  http://localhost:5000

  Type s + enter at any time to create a snapshot of the database
  Watching...

now when I try to access http://localhost:5000/tasks , I get 403 Access to localhost was denied.
what can I do to fix this?
Thanks!


Solution

  • the problem was with the port. changed it to 3001 and it works. still doesn't understand why did this happen in that port.