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

4

13

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!

Garnierite answered 24/1, 2020 at 18:40 Comment(0)
T
29

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",
Tenaculum answered 29/8, 2020 at 17:38 Comment(0)
K
12

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

Kelsey answered 20/6, 2021 at 12:26 Comment(0)
M
1

I had to do:

gatsby develop -h 192.168.xx.xx -p 8080
Marisolmarissa answered 17/10, 2022 at 18:6 Comment(0)
A
0

Your phone and and the computer you are running from needs to be on same wifi/network. I need sometimes to reconnect my phone to the wifi to get it right. Suppose it has to do with the private ip adress the router is assigning to devices.

Then 192.168.1.xx:8000 can be opened on phone browser.

Abomb answered 29/9, 2021 at 13:30 Comment(1)
You'd think so, but no. Also the local address is more likely to be 10.0.0.x:8000Recline

© 2022 - 2024 — McMap. All rights reserved.