Search code examples
bashcmdgatsbymacos-high-sierra

Gatsby develop command fails on macOS High Sierra, no error message shown


I'm very new to Gatsby and have just started reading up on the website's tutorial here. However, I'm having some trouble running the gatsby develop command as it throws an error and displays only this message and nothing else:

Looks like develop for this site is already running, can you visit http://://localhost:8000 ? If it is not, try again in five seconds!

When I click on http://://localhost:8000, the page just says localhost refused to connect.

Below is the output of gatsby info -C:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.4.0 - ~/.nvm/versions/node/v14.4.0/bin/node
    npm: 6.14.5 - ~/.nvm/versions/node/v14.4.0/bin/npm
  Languages:
    Python: 2.7.14 - /usr/local/bin/python
  Browsers:
    Chrome: 85.0.4183.102
    Safari: 11.1.2   
  npmPackages:
    gatsby: ^2.24.54 => 2.24.54   
  npmGlobalPackages:
    gatsby-cli: 2.12.94

I've also tried uninstalling and installing the gatsby-cli, but the issue persists. Also checked if anything's running on port 8000 using lsof -i TCP:8000, but nothing came up.

If someone could shed some light as to where the issue's coming from, I'd greatly appreciate it!

PS: I tried running gatsby build and gatsby serve, and encountered no problems.


Solution

  • This is because of the port of the OS firewall. You can easily fix it by adding a port to the default Gatsby running command (in your package.json):

    gatsby develop -p 8001
    

    Note the -p flag, as you can see in the documentation it change Gatsby's running port. Of course, you can change the 8001 for any desired (and unused) port. Changing it won't affect the Gatsby project because it will readapt the GraphQL playground to it.