Connect Device to Mac localhost Server? [closed] - iphone

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
How do I allow any device, e.g., iPhone, to connect over a WLAN to my Mac's localhost server?
On my Mac, I'm running a "Hello World" HTTP Node.js server that serves a page, which Safari opens successfully, at http://localhost:1337. And, running ipconfig getifaddr en1 in Terminal outputs 192.168.1.9.
But, Safari, on both iPhone & Mac, displays "Safari can't connect to the server" when it tries to open http://192.168.1.9:1337.
I don't think this should involve port forwarding because I only want the HTTP server to be available privately, not publicly.
Related:
Accessing localhost from iPhone (in same network)
https://superuser.com/questions/308451/connect-to-localhost-from-another-computer
https://superuser.com/questions/400752/can-we-run-local-server-over-local-network-without-internet-access
https://serverfault.com/questions/254947/accessing-localhost-xampp-from-another-computer-over-lan-network-how-to

I had the same problem. I turned off my WI-FI on my Mac and then turned it on again, which solved the problem. Click Settings > Turn WI-FI Off.
I tested it by going to Safari on my iPhone and entering my host name or IP address. For example:
http://<name>.local or http://10.0.1.5

Have your server listen on 0.0.0.0 instead of localhost.

I was only able to access my iphone using http://name.local:1337. You have to add the ".local" You can find your computer name under System Preferences/sharing/"Computer Name".

Try enabling Internet Sharing:
Open System Preferences -> Sharing.
Check Internet Sharing to turn it on, it will prompt you to confirm your action, select ok.
If your iPhone is connected using USB, the iPhone USB is checked at the "sharing your connection" list on the right side.
After this, try accessing your local server using your macs ip on wifi.

My problem was the same, but the solution had to do with changing a firewall setting. It turned out that node was set to block incoming traffic. I knew something was up because I used to be able to get to my localhost server from my phone.
Go to System Preferences -> Security & Privacy -> Firewall -> Firewall Options, and then scroll down until you find node and make sure node's setting is set to Allow incoming connections.
After changing the setting, I could reach the localhost server (port 3000) running on my Mac by going to http://192.168.1.11:3000

I solve a similar problem.
connected Mac and iPhone to the same Wi-Fi
change the iPhone Wi-Fi setting, set http proxy to manual and change the Server to you Mac ip address and setting the Port. My Port is 80.
you can input http://<Mac ip>:<your customer server port> in iPhone's safari

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

make sure you phone and mac machine both connected to the same wifi and you good to go your http://<machine-name>.local

Connect your iPhone to your Mac via USB.
Go to Network Utility (cmd+space and type "network utility")
Go to the "Info" tab
Click on the drop down menu that says "Wi-Fi" and select "iPhone USB" as shown here:
You'll find an IP address like "xxx.xxx.xx.xx" or similar. Open Safari browser on your iPhone and enter IP_address:port_number
Example: 169.254.72.86:3000
[NOTE: If the IP address field is blank, make sure your iPhone is connected via USB, quit Network Utility, open it again and check for the IP address.]

I suggest to use the name of the computer, e.g.http://mymac:1337/. Works for me perfect without any configuration required and I don't have to care about changing IP addresses due DHCP.

As posted I followed moeamaya's answer but needed to modify it just a bit to see my work in the Sites directory.
http://[name].local.~[username]/
[name] is as stated already (System Preferences/sharing/"Computer Name")
[username] is found at:
/etc/apache2/users/username.conf
hope this helps!

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

Always use the IP that is shown in your Network settings. It changes when you change location and you use another wireless connection.
For example in my case now it is: 10.0.0.5

also, make sure the server is listening for ur mobile device! for example, by default jekyll only answers requests made by the host machine. this solved my problem:
Connect to a locally built Jekyll Server using mobile devices in the LAN

Related

Minecraft server hosted on PC without internet, just a router/modem [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm wondering if its possible to host a Minecraft server on my PC and have my wife connect to that server without any internet connection. We are willing to get a router/modem or switch if need be. We just can't use internet and need instructions on what to get, how to set it up, and how to use it. My hope is that it is possible to have our computers in the same room, plug our PCs into a router that has no internet service via Ethernet cables, turn on the server on my PC, my wife can type in the IP and we can play together.
Yes you can. I am running a Minecraft server on a separate Linux machine, and me and my brother connect to the Minecraft server from separate computers, all of it from our own wireless LAN and without an Internet connection.
We are using a WiFi router that is not connected to the Internet, the computer running the server is an old laptop, and then we have two additional computers, each running an instance of Minecraft, and it all works fine.
I'm not sure about using only a network switch, because you need to be connected at the IP layer, since you need to specify the internal, private IP address of the computer running the Minecraft server from the Minecraft client in order to join.
So in a nutshell, you will need to download and install the Minecraft server, install the latest Java OpenJDK, run the Minecraft server, read the eula, and last in order for this to work completely offline (that is, we want this to work without an Internet connection), you will need to go into the Minecraft server configuration file, locate the property of online-mode=true and set it to online-mode=false.
This setting basically controls whether or not players authenticate to Mojang's servers before they connect to your server, and it prevents players with cracked clients from connecting to your server, but since you will be hosting and joining from within an internal, private network anyways it does not matter. No one will be connecting to your server from the outside world if there is not a connection to the Internet anyway.
For more details about how to install and run a Minecraft server, there are many guides out there. It's actually pretty simple, if you're comfortable using a console screen and know just a little bit about IP addresses and editing a configuration file with a text editor. For me, I run the Mi ecraft server and I was able to connect to it with my brother and start playing right away, without having to mess around with the server at all.
So there you have it, I hope this helps someone.
The very definition of a server is something that provides resources over the internet:
A server is a computer program or a device that provides functionality for other programs or devices, called "clients", over the Internet.
There is a way that would work the way you intend, but without Ethernet, it runs over WiFi. Go into a world, open the Pause menu, and click Open to LAN. Then you can go to a server menu on another computer and it will show up in the LAN Worlds section. However, this will only run vanilla gameplay.
Just FYI, this question would be considered off-topic here and should be asked in the Gaming or Networking communities.
EDIT: Opening to LAN would work over ethernet too.

View localhost from Iphone using MacBook Pro

So I am attempting to view my localhost from my Mackbook on my iPhone. I am attempting to do so through USB connection with developmental modes on in Safari in both devices. I've tried to connect to localhost 2 ways so far with no success:
First I've opened up my System Preferences on my MacBook. I opened up the sharing option. Then I clicked "Internet Sharing" toggle on the left. I noted my computer name and clicked the option "iPhone USB." I then navigated to <cpuname>.local:4200, with 4200 being the port I'm using in for localhost. This has Safari saying that it cannot reach the server.
Second I opened a terminal and typed "ifconfig" to find my CPU IP address. I then attempted to navigate to my localhost from my phone using <cpuip>:4200 This also failed with Safari saying that it could not connect to the server.
I have done no other configurations and am interested in hearing what I should do. Any help would be greatly appreciated.
Extra Info
The application is a simple Angular application.
Both devices are connected to the same network.
For anybody suffering this problem, I've found a solution using the hint from this link here. The solution was to bind the host to port 0.0.0.0. In the Angular 2+ way, that would mean serving the app with the --host 0.0.0.0 --disableHostCheck flags. Good luck!

Does hosts file exist on the iPhone? How to change it? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am developing an application that query to the server. In my Mac, I use the hosts file to change the dns to point to a local server within my local area network.
Now I need to test it with my iPhone, the problem is that my iPhone does not recognize that server due to the missing configuration for dns.
On my Mac or Windows, I simply add: 192.168.0.20 http://www.google.com to the hosts file.
Now how do I let my iPhone know the URL: http://www.google.com ?
Another option here is to have your iPhone connect via a proxy. Here's an example of how to do it with Fiddler (it's very easy):
http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html
In that case any dns lookups your iPhone does will use the hosts file of the machine Fiddler is running on. Note, though, that you must use a name that will be resolved via DNS. example.local, for instance, will not work. example.xyz or example.dev will.
This doesn't directly answer your question, but it does solve your problem...
What make of router do you have? Your router firmware may allow you to set DNS records for your local network. This is what I do with the Tomato firmware
Not programming related, but I'll answer anyway. It's in /etc/hosts.
You can change it with a simple text editor such as nano.
(Obviously you would need a jailbroken iphone for this)
I just edited my iPhone's 'hosts' file successfully (on Jailbroken iOS 4.0).
Installed OpenSSH onto iPhone via Cydia
Using a SFTP client like FileZilla on my computer, I connected to my iPhone
Address: [use your phone's IP address or hostname, eg. simophone.local]
Username: root
Password: alpine
Located the /etc/hosts file
Made a backup on my computer (in case I want to revert my changes later)
Edited the hosts file in a decent text editor (such as Notepad++). See here for an explanation of the hosts file.
Uploaded the changes, overwriting the hosts file on the iPhone
The phone does cache some webpages and DNS queries, so a reboot or clearing the cache may help. Hope that helps someone.
Simon.
It might exist, but you cannot change it on a non-jailbreaked iPhone.
Assuming that your development webserver is on a Mac, why don't you simply use its Bonjour name (e.g. MyMac.local.) instead of myrealwebserverontheinternet.com?
Don't change the DNS on the phone. Instead, connect with wifi to the local network and you are all set.
At my office, we have internal servers with internal DNS that are not exposed to the Internet. I just connect with iPhone to the office wifi and can then access them fine.
YMMV, but instead of configuring the phone DNS, it feels to me that just setting up local internal DNS and wifi is a cleaner and easier solution.
In case anybody else falls onto this page, you can also solve this by using the Ip address in the URL request instead of the domain:
NSURL *myURL = [NSURL URLWithString:#"http://10.0.0.2/mypage.php"];
Then you specify the Host manually:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL];
[request setAllHTTPHeaderFields:[NSDictionary dictionaryWithObjectAndKeys:#"myserver",#"Host"]];
As far as the server is concerned, it will behave the exact same way as if you had used http://myserver/mypage.php, except that the iPhone will not have to do a DNS lookup.
100% Public API.
No, an iPhone application can only change stuff within its own little sandbox. (And even there there are things that you can't change on the fly.)
Your best bet is probably to use the servers IP address rather than hostname. Slightly harder, but not that hard if you just need to resolve a single address, would be to put a DNS server on your Mac and configure your iPhone to use that.

iPhone - access XAMPP server (localhost) on my mac in the same network

I want to create an iPhone app which makes calls to a web service. For testing, I want to first create the API calls on my mac (server running XAMPP) and if it works fine there I want to port it to the actual server.
If my iPhone and mac are on the same network, can I access the web service using the IP address of my mac?
Thanks.
Any time someone answers with "why not," ignore the post. This just takes up space and adds absolutely no value...their post imitating their life.
Anyway, I access my laptop localhost (WAMP stack) from my iPod Touch by entering the IP address of my laptop on my Touch location bar. There is some configuration that needs to happen for this to work. I found what I needed at:
http://www.frihost.com/forums/vt-88381.html
Good Luck!
I can not speak about actual development, however I access intranet pages from a Ipod Touch all the time by either typing http ://ip or http://local_dns_name
As long as the iphone / ipod is on the network correctly (e.g. through standard wifi and not 3g/whatever) you should be able to access any and all local resources.
What I do:
Connected to the same network, I go in to the wireless settings and create a manual proxy that points to my machine. I use Charles proxy for testing a lot/seeing traffic, works like a charm and it lets me use my macbook hosts file so I don't need to do any funky listening rules in apache - just the same vhost settings I use on my machine already.
http://www.charlesproxy.com/documentation/faqs/using-charles-from-an-iphone/
Why not?
Have you tried it and have some problems?

How do you monitor network traffic on the iPhone? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
The community reviewed whether to reopen this question 9 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
We are looking for a Wireshark-like tool to use on the iPhone to test a 3rd party application before partnering with the 3rd party. Any suggestions?
A man-in-the-middle proxy, like suggested by other answers, is a good solution if you only want to see HTTP/HTTPS traffic.
The best solution for packet sniffing (though it only works for actual iOS devices, not the simulator) I've found is to use rvictl. This blog post has a nice writeup. Basically you do:
rvictl -s <iphone-uid-from-xcode-organizer>
Then you sniff the interface it creates with with Wireshark (or your favorite tool), and when you're done shut down the interface with:
rvictl -x <iphone-uid-from-xcode-organizer>
This is nice because if you want to packet sniff the simulator, you're having to wade through traffic to your local Mac as well, but rvictl creates a virtual interface that just shows you the traffic from the iOS device you've plugged into your USB port.
Note: this only works on a Mac.
You didnt specify the platform you use, so I assume it's a Mac ;-)
What I do is use a proxy. I use SquidMan, a standalone implementation of Squid
I start SquidMan on the Mac, then on the iPhone I enter the Proxy params in the General/Wifi Settings.
Then I can watch the HTTP trafic in the Console App, looking at the squid-access.log
If I need more infos, I switch to tcpdump, but I suppose WireShark should work too.
I use Charles Web Debugging Proxy it costs but they have a trial version.
It is very simple to set up if your iPhone/iPad share the same Wifi network as your Mac.
Install Charles on your Mac
Get the IP address for your Mac - use the Mac "Network utility"
On your iPhone/iPad open the Wifi settings and under the "HTTP
Proxy" change to manual and enter the IP from step (2) and then Port
to 8888 (Charles default Port)
Open Charles and under the Proxy Settings dialogmake sure the
“Enable Mac OS X Proxy” and “Use HTTP Proxy” are ticked
You should now see the traffic appearing within Charles
If you want to look at HTTPS traffic you need to do the additional 2 steps download the
Charles Certificate Bundle and then email the .crt file to your
iPhone/iPad and install.
In the Proxy Settings Dialog SSL tab, add the specific https top
level domains you want to sniff with port 443.
If your Mac and iOS device are not on the same Wifi network you can set up your Mac as a Wifi router using the "Internet Sharing" option under Sharing in the System Preferences. You then connect your device to that "Wifi" network and follow the steps above.
Run it through a proxy and monitor the traffic using Wireshark.
For Mac OS X
Install Charles Proxy
In Charles go to Proxy > Proxy Settings. It should display the HTTP proxy port (it's 8888 by default).
For Windows
Install Fiddler2
Tools -> Fiddler Options -> Connections and check "Allow remote computers to connect"
General Setup
Go to Settings > Wifi > The i symbol > At the bottom Proxy > Set to manual and then for the server put the computer you are working on IP address, for port put 8888 as that is the default for each of these applications
ARP Spoofing
General notes for the final section, if you want to sniff all the network traffic would be to use ARP spoofing to forward all the traffic from your iOS to a laptop/desktop. There are multiple tools to ARP spoof and research would need to be done on all the specifics. This allows you to see every ounce of traffic as your router will route all data meant for the iOS device to the laptop/desktop and then you will be forwarding this data to the iOS device (automatically).
Please note I only recommend this as a last resort.
On a jailbroken iPhone/iPod capturing traffic is done nicely by both "tcpdump" and "pirni"- available in the cydia repository. Analysis of these data are done by tranfering the capture over to another machine and using something like wireshark. However, given the active development that seems to be going on with these tools it's possible that soon the iPhone will handle it all.
The best solution I have found that Works:
Connect your device thru USB
And type these commands:
rvictl -s UDID - (id of device 20 chars, you can locate 4t in iTunes or organiser in Xcode)
sudo launchctl list com.apple.rpmuxd
sudo tcpdump -n -t -i rvi0 -q tcp
OR just sudo tcpdump -i rvi0 -n
If rvictl is not working install Xcode
For more info:
Remote Virtual Interface
http://useyourloaf.com/blog/2012/02/07/remote-packet-capture-for-ios-devices.html
Without knowing exactly what your requirements are, here's what I did to see packts go by from the iPhone: Connect a mac on ethernet, share its network over airport and connect the iPhone to that wireless network. Run Wireshark or Packet Peeper on the mac.
Here is another way http://www.tuaw.com/2011/02/21/how-to-inspect-ioss-http-traffic-without-spending-a-dime/
I didn't see Roger Nolan's reply, the above link is same workflow with a different tool.
Depending on what you want to do runnning it via a Proxy is not ideal. A transparent proxy might work ok as long as the packets do not get tampered with.
I am about to reverse the GPS data that gets transferred from the iPhone to the iPad on iOS 4.3.x to get to the the vanilla data the best way to get a clean Network Dump is to use "tcpdump" and/or "pirni" as already suggested.
In this particular case where we want the Tethered data it needs to be as transparent as possible. Obviously you need your phone to be JailBroken for this to work.
Try Debookee on Mac OS X which will intercept transparently the traffic of your iPhone without need of a proxy, thanks to MITM, as stated before.
You'll then see in real time the different protocols used by your device.
Disclaimer: I'm part of the development team of Debookee, which is a paid application. The trial version will show you all functionnalities for a limited time.
A general solution would be to use a linux box (could be in a virtual machine) configured as a transparent proxy to intercept the traffic, and then analyse it using wireshark or tcpdump or whatever you like. Perhaps MacOS can do this also, I haven't tried.
Or if you can run the app in the simulator, you can probably monitor the traffic on your own machine.
Com'on, no mention of Fiddler? Where's the love :)
Fiddler is a very popular HTTP debugger aimed at developers and not network admins (i.e. Wireshark).
Setting it up for iOS is fairly simple process. It can decrypt HTTPS traffic too!
Our mobile team is finally reliefed after QA department started using Fiddler to troubleshoot issues. Before fiddler, people fiddled around to know who to blame, mobile team or APIs team, but not anymore.