How to run localhost website in Android phone running on laptop
P粉369196603
2023-09-03 16:09:33
<p>I recently started developing a website. However, I'm having trouble running it on localhost. When I type http://localhost into my web browser.
I recently started developing a website. However, I'm having trouble running it on localhost. When I type http://localhost into my web browser.
CSS</p>
Your localhost is the machine that runs your code, it acts like a server, but locally. If you want to access the site on your mobile phone, you'll need to find your computer's IP address. You can get this by opening a command prompt and typing ipconfig and checking the IPv4 address, there may be two, try one of them. Then make sure your phone and computer are connected to the same network (e.g. let computer and phone connect to the same WiFi. But make sure that WiFi is not private), then you can use this IP on your phone, then the port number , for example
192.158.1.38:4000
, where4000
is the port number.Judging from your
css
tags, I guess you want to test the responsive code, I can suggest you check the browsing by right-clicking anywhere on the browser window and clicking "Inspect" From here, you can switch between mobile and desktop views and even choose a different mobile device to see how your site will look on those devicesIf you need more help, please let me know. Hope this helps you :)
Please follow the steps below: Step 1: Open CMD and write
ipconfig
Step 2: Find the
ipv4 address
, similar toIPv4 address: 192.168.x.x
Step 3: Write the address into your mobile phone and add
:PORT
PORT=write the port number your website runs on at the end, it will be displayed inbrowser url
中vscode
in code> orlive server
extensionWebsite:
http://192.168.x.x:PORT