The question is about localhost, Swift URL, NetBeans and Xampp - ios

everyone, I have a question to ask about "localhost"
I am a newbie and use NetBeans and Xampp as DATABASE to connect with Swift.
I use "http://localhost/" as my URL on the simulator of Mac, which works fine.
But when I change to my physical device, it has an error " can not connect to the server", how can I solve this problem?
And another question, if one day I publish the APP, what URL should I use? Is it still "http://localhost/" or anything else? I am really confused, can someone give me some advice? I would really appreciate!

localhost is 127.0.0.1 address, used only in current machine.
When you using simulator, simulator run in same machine with server, it will success access 127.0.0.1 address.
If you using real device, please find your server ip with command ifconfig and use that in App.
Hope to help you.

As was written in the comments, http://localhost/ only works on the current device (similar if you are using http://127.0.0.1). The simulator is running on your Mac, so it will work.
Since the physical device is not on your Mac, it will not work. So, for testing, you might want to set up a test server on your computer or on another machine. Then, you would replace the URL with the IP address or hostname of the server. For production, you would need to set up a server or find a hosting service. Then, you would use the URL for whatever server you go with in your app instead of http://localhost/.

Related

How can I access my localhost on my computer from my Android device?

I have a web application written in ASP.NET MVC 5. I simply can open it from the browser with this localhost:14920 in my computer, but I want to access the same application from my Android device's browser while my laptop and Android device are in the same network. I don't know how to access it from Android.
Note: when I type 127.0.0.1 in the Android browser I can access the IIS server, but when I type 127.0.0.1:14920 it prints Bad Request - Invalid Hostname. How can I fix this issue?
You can configure IISExpress for remote access
http://www.ryadel.com/en/iis-express-allow-external-requests-remote-clients-devices/
or just change the hosting to IIS as the earlier commenter mentioned.
Try with replacing 127.0.0.1 with your IPv4 address.
I have used ngrok in the past, when needing to hit my development machine, or have someone else hit it. It is a very useful tool and very simple to install.
Once you download it, it's just a simple command line:
https://ngrok.com/docs#expose
ngrok http 80
(That is for traffic on port 80) Since your port above looks different it would be:
ngrok http 14920
That will give a URL that you can hit or any machine or device.

Issue with Xcode Server: No services available

I'm trying to run a Xcode server with remote access.
I've been trying to log in from a client/node PC, with no success. There's a message with the IP and a warning "No services unavailable".
Is there something I'm missing here?
Screenshot is attached.
Thanks.
Since from attached picture everything is running perfectly locally, I'm almost sure that the problem is in your router. So on router in port forwarding you have to open:
For Xcode Integration the only ports needed are 20300,20343-20345
For Website 80,443
And you have to make sure that you're have global IP address

why I am not able to access rails localhost on my mobile or other computer

I am trying to access my localhost of rails running project on my mobile device.
This is how I am trying.
http://ip:3000
But it says the webpage is not available.
I tried with another port as well and It doesn't work even there?
What's wrong here? I use to check earlier this way.
Please guide
Try running this code below to your server:
rails s -b 0.0.0.0
This worked for me!
Just give:
ip = your phone's ip address
(Check it in connection information if you are running this on Ubuntu)
ip:3000/your_page if you do not have mapped your root to some page.
Else ip:3000 will work if you have mapped root to some page.
Try it in Chrome and see as it doesn't need any http or https it automatically selects the required one.
Here is how I did it
Put both your computer and phone on the same wifi network
rails s -b 0.0.0.0
routerlogin.net (or however you access your router it will say on the back of router)
get attached devices to the router. Note your computers ip. Mine was 10.0.0.20
on phone go to 10.0.0.20:3000 (but use the ip for your computer from step 4)

Error when testing app from mobile device - ERR_CONNECTION_REFUSED

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.

Can't view Rails app on Windows7 via mac local address

My app runs on localhost:3000 on my mac
My mac has its own local address eee.local
Other computers in the office, including other windows machines
can connect to eee.local:3000 and use the the rails app.
However we had once case where one person's windows7 machine
could not connect. I brought a brand new windows7 machine for
IE testing purposes and it doesn't connect either.
I tried turning of the firewall and that doesn't work.
I tried using the ip instead eg. 192.160.0.3:3000 but that doesn't work.
I'm not really sure how else to check, or search for this problem
Anything Im overlooking?
Another thing to try is to install iTunes. Sounds silly at first but installing iTunes gives your Windows machine Bonjour service discovery (enabled by default on Macs and Ubuntu desktops) which would let you resolve .local addresses.
Accessing via the IP really should have worked but if you've already turned off firewalls and the machines are on the same network then enabling Bonjour (by installing iTunes) is worth a shot.
Is the other Windows machine on a different subnet? That could cause the issue.
You need to tell the web server to listen on all interfaces like so:
./script/server 0.0.0.0:3000

Resources