I need some help accessing a server that I have running on my mac. So basically my setup consists of mac on which I'm running my server and also using XCode to run the app on an iPhone connected via USB. And then both this iPhone and the mac are on the same wiFi network which is a personal hotspot that I have running on a different iPhone. I'm trying to access localhost from the iPhone by basically using my mac's IP address and the right port: http://IPADDRESS:PORT/, however this doesn't seem to work. Any ideas as to what may be going on here and potential workarounds or solutions. Connecting to a non hotspot, traditional wifi network is not an option at the moment.
Thanks!
This will work if you have it set up correctly; I am doing it right now. Remember that you have to bind the server to 0.0.0.0 — not 127.0.0.1 — if you want to connect from non-localhost IPs. Also check your system firewall.
If you're still having trouble, Tailscale is another solution that may help — https://tailscale.com
I suggest you take a look at using ngrok as a solution, this will create a secure tunnel and expose the service running on your Mac through a url.
You'll need to create an account and retrieve your auth token.
You can then install it using Homebrew by running in Terminal: brew cask install ngrok
Once installed, connect your account by typing into Terminal: ngrok authtoken [auth_token]
To start a tunnel, type into Terminal: ngrok [protocol] [port number]
For example, to start a tunnel to a HTTP server running on your mac: ngrok http 80 (or ngrok http 443 for HTTPS)
If its a custom TCP protocol use: ngrok tcp [port] (or ngrok tls [port] if using TLS)
This will then give you a URL to use in your app. On free accounts, the URL will change on each restart, paid accounts get a static URL option.
If you don't have Homebrew, download it from and follow instructions on: https://ngrok.com/download
Related
I'm running a Nginx Web server on my Linux system and I would like to access it on my iPhone (Safari or through my iOS app) when I connect it through USB cable.
How can I do it? is there any available solution?
Having iPhone and Linux system in a same network and access through its iP is not a solution here.
You can use ngrok.
Here is a step-by-step guide:
Download ngrok (https://ngrok.com/download) and move executable to /usr/bin/.
Register here and copy your auth token.
Open the terminal (Ctrl+Alt+T or Ctrl+Alt+F3) and type:
cd
ngrok authtoken <YOUR_AUTHTOKEN>
ngrok http 80
It will give you some URL address. Open it on your iPhone.
Your home page will be shown.
More info on ngrok: https://ngrok.com/docs/secure-tunnels
I have a server running on localhost:5000 on my desktop, and when I make http requests through my react-native app when running on the iOS simulation to it, it works. However, when I connect to a real device, the http requests don't work. What am I doing wrong? Is there something I have to configure?
localhost in your desktop is not the same ip of the localhost of your device.
Get the ip of your computer by typing ifconfig in a terminal, then replace localhost by this ip, you should type something like that in your device browser:
192.168.0.23:5000
Maybe my answer is too late but I ran into a similar situation today and I got it to work by running my node server using the IPv4 of my desktop and then making the request to that IP.
For example, I am running my nodejs development server at http://192.168.0.135:3000(local IP of my desktop) instead of localhost and then I make the fetch API request from my react-native app to http://192.168.0.135:3000/.
Just make sure your nodejs server and your app are on the same local network. My react-native server (metro bundler) is running on a separate PC also in the same wifi network.
If your are on macOS go to settings -> Wifi / and show more,
on bottom you see "IP address", it's your correct localhost for ios physical device !
I'm hosting a .NET Core HTTP application on localhost using Kestrel on an available port for some browser-based UI tests, but when trying to access it using real iOS devices with BrowserStack Automate with BrowserStackLocal.exe, Safari consistently refuses load the page.
I've tried various parts of the IP ranges documented here, but none have been successful. Desktop browsers (Chrome, IE, Edge and Firefox on Windows, Safari on macOS Mojave) and real Android devices work as expected.
I've also tried using the local IP address of the machine and the fully-qualified domain name (FQDN) as described here, but neither work portably as Windows Firewall blocks the connections even through BrowserStack Automate can resolve the address.
Port 80 is not a viable solution as developers' machines will have IIS running on their machines using that port, so it is not available for other purposes.
Given the following constraints, what are the workable solutions?
Hosted on HTTP.
Runs without admin privileges (i.e. no reconfiguring the firewall or using privileged port numbers <1024).
At least two possible port numbers to use so that if one is in use there's at least one alternate to try.
No additional manual setup required to run the tests (should just be the command dotnet test).
On the iOS devices, try resolving http://bs-local.com:5000 instead of http://localhost:5000.
You can access the site using http://bs-local.com:5000, But make sure to disable the host check for webpack using disableHostCheck: true in configuration.
For angular cli users, to disable to the host check you need to use --disable-host-check like ng serve --port 4200 --disable-host-check
This is from BrowserStack's support:
a) On Safari
Previously, accessing local websites with 'localhost/127.0.0.1' in the URL was not supported on iOS devices running iOS versions 10 and above.
However, to make sure that your website loads with 'localhost' in the URL, we now modify the URL to http://bs-local.com on these devices. This helps in loading your website in an expected manner. The same is mentioned here.
In the screenshot you've shared, you can see the redirection to bs-local.com as well.
It seems that your localhost website is configured to be accessible only via specific hostnames such as 'localhost'. Thus, you face the reported error.
To be able to test your localhost website via Safari on iOS devices, I would recommend configuring your localhost website to be accessible via the private IP address of your local machine.
Once done, you can access your localhost website as http://<private_IP_address:port> and this should work.
I would also encourage reading through this guide to understand how you could achieve the above: https://www.notion.so/Testing-localhost-on-iOS-devices-1ceb5e274cee46d7ac538b71304919b4
b) On Chrome
Due to restrictions imposed by Safari, testing localhost websites on Chrome is not supported by default on iOS devices.
The problem arises with the usage of the domain 'localhost'. We are actively trying to find alternatives for this behavior as well.
However, in the meantime, you can access your localhost website via the private IP address as mentioned above via Chrome browser on iOS devices as well.
Once you make the necessary changes to your configuration to allow your localhost website to be accessible via the private IP address, you can test your localhost website via Chrome on iOS as well.
Feel free to reach out should you need any further assistance!
Note: The private IP address is not the same as 127.0.0.1. You can use this article to identify the private IP address of your machine.
Regards,
Reehan
BrowserStack Support
Did you try changing the 'localhost' with the IP address of the machine (where the web is hosted)?
For instance - If the IP for the machine on which application/webpage is hosted is 22.22.22.22, then change http://localhost:3000/index.html to http://22.22.22.22:3000/index.html in your test
They have mentioned the same here - https://www.browserstack.com/question/663
If you are using Angular CLI then please run command
ng serve --host 0.0.0.0 --port xxxx
This will make sure that you would be able to access application using your IP and port specified. Once done you should be able to access your application using browser stack iPhone device browsers using IP and port rather than localhost.
After upgrading to OSX Yosemite, I can no longer test my app on a mobile device by using my development machine's (MacBook Pro) IP address. For example, I used to be able to view a Rails app on a phone by going to http://192.168.0.4:3000, but now I get the following error:
ERR_CONNECTION_REFUSED
I get the same error when testing an AngularJS app using the grunt server running at http://192.168.0.4:9000
Any help will be greatly appreciated.
It could help to bind the server to your local IP, like
rails s -p9000 -b192.168.0.4
to start your rails app
Consider giving a try to Pow. Its pretty simple to install, and a great solution to share a local development across multiple devices.
Like it explains in their homepage, you can install it with just :
curl get.pow.cx | sh. To prevent any errors, install in Terminal app outside a Tmux session.
And just symlink your app :
cd ~/.pow
ln -s /path/to/myapp
You can access your app at http://myapp.dev/, and at http://myapp.[your ip address].xip.io from another device.
Not a direct response to your issue, but an alternative to setting yourself a configuration in your preferences.
Turn IPv6 off. It Prevented me from connecting to my localhost from other computers on my LAN. And, with the newer versions of OSX there is no way to turn it off in the Network Preferences Panel so you have to do it from terminal.
Open Terminal and enter to turn it off:
networksetup -setv6off Wi-Fi
And this to turn it back on:
networksetup -setv6LinkLocal Wi-Fi
If you are connected via Ethernet or something else just run this command to list the available options:
networksetup -listallnetworkservices
and replace "Wi-Fi" with the appropriate device.
I don't have a mac, but that seems to be the server not accepting connections, if that is the case, it's only accepting localhost connections, try binding de server to accept all connections or bind it to 0.0.0.0 ip
Can you access that IP from Browser? are you sure your IP is in the same range with 192.168.0.4? It is your mobile device connected on the same network? Maybe you used internet sharing before update to Yosemite and now is off?
I think your IP address changed. Telnet from console(terminal) your I.P. port. If 192.168.0.4 is your real Ip then maybe add(as root or via sudo) an entry in /etc/host file an entry as 127.0.0.1 192.168.0.4. Restart network or reboot. Also you can try nmap ( on ip to see open ports). Nmap has been ported to OSX just google for installer.
I am trying to connect to CalDAV server from iPad, iOS v7.0.2(11A501), that is running on HTTP port 8080. It failed to connect.
Using Fiddler tool I have found that iPad CalDAV client is sending requests to port 443 and to port 80 instead of the one I specify in 'Server' field.
Being able to run the server on port 80 only in the development environment is inconvenient.
Has anybody experienced this issue and are there are any solution?
Well, my iPad is setup to a Mavericks calendar server. Which is running on https://xxx.local:8443/.
So the answer to your question seems to be Yes. It does support non-standard SSL ports. (This is on iOS 7.0.5/6).
What configuration data do you provide to iOS? Could it be that it initially connects to the right port but then the server is somehow misconfigured and redirects the client to a standard port?
Which CalDAV server do you use?