Reputation: 200
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.
> [email protected] 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!
Upvotes: 3
Views: 2240
Reputation: 1
Search for AirPlay receiver and uncheck it if you are a mac user. Worked for me on port 5000.
Reason - This is apparently due to the new AirPlay functionality. Control Center stops listening to those ports when I turn off “AirPlay Receiver” in the “Sharing” System Preference:
Source- https://developer.apple.com/forums/thread/682332
Upvotes: 0
Reputation: 81
Maybe you are using MacOS Monterey(or maybe other versions in the future). Check the reason here: https://developer.apple.com/forums/thread/682332
Cause: Control Center on Monterey listening to port 5000 and port 7000
Fix: change the port to avoid range 5000-7000, like following,
"server": "json-server --watch db.json --port 3000"
or just remove the customised argument --port 3000
as this is the default value
Upvotes: 8
Reputation: 200
the problem was with the port. changed it to 3001 and it works. still doesn't understand why did this happen in that port.
Upvotes: 7