Connect device to local Mac server?

How do I allow any device, such as an iPhone, to connect via WLAN to a local Mac server?

On my Mac, I run the "Hello World" Node.js HTTP server serving the page that Safari opens successfully, at http://localhost:1337 . And, working ipconfig getifaddr en1 in terminal outputs 192.168.1.9 .

But, Safari, on both the iPhone and Mac, displays “Safari cannot connect to the server” when it tries to open http://192.168.1.9:1337 .

I don’t think this should have included port forwarding , because I want the HTTP server to be available privately and not publicly.

on this topic:

+71
iphone lan localhost localserver wlan
Sep 30
source share
14 answers

I had the same problem. I turned off my WIFI on my Mac and turned it on again, which solved the problem. Click Settings> Disable WIFI.

I tested it by going to Safari on my iPhone and entering my hostname or IP address. For example: http://<name>.local or http://10.0.1.5

+43
Sep 26 '14 at 18:14
source share

I managed to access my iphone using http://name.local:1337 . You must add ".local". You can find the name of your computer in the "System Preferences / Sharing /" Computer Name.

+26
Feb 19 '14 at 15:01
source share

Listen to your server on 192.168.1.9:1337 , not localhost:1337 , i.e. 127.0.0.1:1337 .

+25
Sep 30
source share

Try enabling internet sharing:
Open System Preferences → Share. Check the box "Share Internet" to enable it, it will ask you to confirm your action and select "OK". If your iPhone is connected via USB, the iPhone USB is checked in the "Share your connection" list on the right.
After that, try accessing the local server using your macs ip on wifi.

+14
Oct 12 '14 at 18:39
source share

My problem was the same, but the solution was to change the firewall settings. It turned out that the node is configured to block incoming traffic. I knew that something was wrong because I used to access my local server from my phone.

Go to "System Preferences" → "Security and Privacy" → "Firewall" → "Firewall Settings", and then scroll down until you find the node and make sure that the node parameter is set to " Allow incoming connections . "

After changing the setting, I was able to access the local server (port 3000) running on my Mac by going to the address http://192.168.1.11haps000

+7
Dec 15 '16 at 23:40
source share

MacOS Sierra users can find their auto-generated vanity URL by going to System Preferences > Sharing and checking the computer name under text input. To access it, enter this URL and your port number (for example, your-name.local: 8000) on your iPhone over the same Wi-Fi connection as your computer.

+4
Nov 03 '17 at 16:53 on
source share

I suggest using a computer name, for example http://mymac:1337/ . Works perfectly for me without any configuration, and I don’t have to worry about changing IP addresses due to DHCP.

+3
Sep 30
source share

make sure your phone and Mac are connected to the same Wi-Fi and you can use your http://<machine-name>.local

+3
May 24 '17 at 6:03 a.m.
source share

I am solving a similar problem.

  • connected Mac and iPhone to the same Wi-Fi
  • change the iPhone Wi-Fi setting, set the http proxy to manual, change the server to your Mac IP address and configure the port. My port is 80.

image one

image two

  • you can enter http://<Mac ip>:<your customer server port> in iPhone Safari
+3
Feb 13 '18 at 6:23
source share

As indicated, I followed the moeamaya answer, but I needed to modify it a bit to see my work in the Sites directory.

 http://[name].local.~[username]/ 

[name] already specified (System Preferences / Sharing / "Computer Name")

[username] is located at:

 /etc/apache2/users/username.conf 

hope this helps!

+2
Aug 02 '14 at 3:20
source share
  1. Connect your iPhone to your Mac via USB.

  2. Go to Network Utility (cmd + space and enter "network utility")

  3. Go to the "Information" tab

  4. Click on the drop-down menu that says “Wi-Fi” and select “iPhone USB,” as shown here:

    Photo for Step 4

  5. You will find an IP address such as "xxx.xxx.xx.xx" or similar. Open the Safari browser on your iPhone and enter IP_address: port_number

    Example: 169.254.72.86lla000

[NOTE. If the IP address field is blank, make sure your iPhone is connected via USB, exit Network Utility, open it again and check the IP address.]

0
Aug 16 '18 at 0:46
source share

I tried everything on this page, but http://<name>.local:<PORT> worked on my iPhone after I left and restarted Safari ...

0
Jan 04 '19 at 7:04
source share

Always use the IP address specified in the network settings. It changes when you change location and use a different wireless connection.

For example, in my case now it is: 10.0.0.5

0
Jan 12 '19 at 1:47
source share

also make sure server is listening ur ur mobile device! for example, by default, jekyll only responds to requests made by the host machine. this solved my problem:

Connect to a locally built Jekyll server using mobile devices on the local network

-one
Dec 18 '17 at 19:21
source share



All Articles