Json-server: its showing cannot get/ on default port:3000

Created on 21 Sep 2018  路  9Comments  路  Source: typicode/json-server

I am using npm

I used below code in gitbash
npm run json-server --watch db.json

Then I checked my localhost:3000, it showing cannot get.

Although after running the command it display the following

\{^_^}/ hi!

  Loading db.json
  Done

  Resources
  http://localhost:3000/todos

  Home
  http://localhost:3000

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

Most helpful comment

I don't think you installed it globally, but anyway, you can run it with

npx json-server db.json --watch

All 9 comments

Try launch without npm on begining:
json-server --watch db.json

command not found

Are you install this package globally?

yeah

I don't think you installed it globally, but anyway, you can run it with

npx json-server db.json --watch

Ok. npm is not for runing json-server or any package is for install and launch scripts from package.json.

  • try to install json-server globally again npm install -g json-server
  • try to launch json-server again
  • open url: http://localhost:3000/todos. If you open just http://localhost:3000 you get a blank page
  • maybe try to change the port --port 3030
  • check your path to db.json

@sahilkatia Is your issue fixed? Shall we close the ticket?

What is the use of npx front of json-server db.json --watch
because json-server --watch db.json doesn't work with me

npx json-server public/db.json --port 8000 worked for me

Was this page helpful?
0 / 5 - 0 ratings