Trying to view localhost on phone hosted my laptop
Answered
Peterbald posted this in #help-forum
PeterbaldOP
Hey there. I'm trying to use my phone (Android) to load my localhost environment thar's being hosted on my computer. I'm using Next 13.4.1 and I'm not sure if there's something that I need to enable. Both devices are on the same Wi-fi network. I found my local IP.
Is there anything that I need to enable or set up? Thanks! 🙂
Is there anything that I need to enable or set up? Thanks! 🙂
Answered by Peterbald
I figured it out. I'm using Nrwl and didn't think to consider it's project.json or hostname variable workaround.
@Rhinoceros Auklet was right, but with different syntax
Thanks, all!
@Rhinoceros Auklet was right, but with different syntax
nx serve <appname> --hostname 0.0.0.0Thanks, all!
17 Replies
@Peterbald Hey there. I'm trying to use my phone (Android) to load my localhost environment thar's being hosted on my computer. I'm using Next 13.4.1 and I'm not sure if there's something that I need to enable. Both devices are on the same Wi-fi network. I found my local IP.
Is there anything that I need to enable or set up? Thanks! 🙂
nothing else to set up, you already did everything. just go to your phone and access http://<computer ip>:3000
PeterbaldOP
Thanks for replying!
Does it have to be :3000? I have another older Next project that works fine under :3000, but not this one. The newer project runs under :4200 on my machine.
Does it have to be :3000? I have another older Next project that works fine under :3000, but not this one. The newer project runs under :4200 on my machine.
@Peterbald Thanks for replying!
Does it have to be :3000? I have another older Next project that works fine under :3000, but not this one. The newer project runs under :4200 on my machine.
then just substitute the port
if on computer you can access it at localhost:12345 then on your phone you can access it at <computer ip>:12345
if on computer you can access it at localhost:12345 then on your phone you can access it at <computer ip>:12345
same for any port
PeterbaldOP
Hmm. Still no luck. This should be working out of the box.
Dunker
@Peterbald there is a thing like
yourip:port for mobiles. i was accessing with thatbut you should use wifi to access that port
PeterbaldOP
It should, you're right.
I might have something blocking it via my WiFi settings , but another Next project that I use works via my phone.
Dunker
now i tried it on mine
my pc on ethernet, and mobile on wifi
i wrote my ip to chrome and port
worked
you can always use ngrok
if theres some issue with your local wifi
Rhinoceros Auklet
npm start --host 0.0.0.0PeterbaldOP
I figured it out. I'm using Nrwl and didn't think to consider it's project.json or hostname variable workaround.
@Rhinoceros Auklet was right, but with different syntax
Thanks, all!
@Rhinoceros Auklet was right, but with different syntax
nx serve <appname> --hostname 0.0.0.0Thanks, all!
Answer