2

I am running Node.js in a localhost on my Raspberry Pi 4. I would like to access the localhost in the browser of my phone. I have set up a stand alone access point on my Raspberry Pi and connected my phone to it. However, apparently I cannot access the localhost on my phone.

I also tried with 127.0.0.1:8080.

What do I need in order to get access to the localhost from my phone?

enter image description here

1
  • localhost means the same machine, it never refers to a different machine. – Michael Hampton Oct 9 '20 at 20:42
3
  1. Find your Raspberry pi ip address for the access point.
  2. Pass it in instead of localhost.
1
3

I would like to access the localhost in the browser of my phone

No, you don't. Although it is theoretically possible, it is most certainly not what you want.

What you want is to access your node.js application from your phone.

A network drawing will make this more clear.


          +-----------+                   +----------+
 localhost|           |    WiFi network   |          | localhost
      +===+   PI      +-------------------+ phone    +====+
          |           |                   |          |
          +-----------+                   +----------+

In general, your localhost is local for your host only. It resolves to 127.0.0.1, and the 127.0.0.0/8 network on your phone is completely separated from the 127.0.0.0/8 network on your Pi.

What you want is to access the Pi over the WiFi network. For that, use the WiFi-IP of your Pi instead of your localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.