Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I access my local Gatsby site on my phone

I am new to Gatsby, and I will be starting my first project today. I want to be able to test the site on my android phone to ensure mobile compatibility rather than using chrome dev-tools.

I have only ran a few commands so far.

1) Gatsby new site-name

2) cd site-name

3) gatsby develop --host 0.0.0.0 -p 8080

Everything compiles properly, and I can access the default Gatsby page through localhost:8080 or 192.168.1.81:8080 on the host laptop, but when i attempt to access from my android phone, it says that the server is unreachable. I am running windows 10 on my laptop, and so far Ive checked the firewall, and I've tried a few different ports as well. If someone has dealt with this issue and could help me that would be much appreciated!

like image 742
Byron Hill Avatar asked Jan 24 '20 18:01

Byron Hill


2 Answers

I don't know why they blocked access by default :/ But you can access it by adding -H 0.0.0.0 to develop command. For example change your package.json to:

"develop": "gatsby develop -H 0.0.0.0",
like image 158
Dominic Avatar answered Oct 12 '22 04:10

Dominic


you can fix this issue by using this command

gatsby develop -H 0.0.0.0

more information : from here

after you can use your pc ip address with the port number to debug gatsby site on your mobile

Example :

192.168.1.4:8000

like image 45
Vihanga nivarthana Avatar answered Oct 12 '22 06:10

Vihanga nivarthana