0

I have a web application that runs on my macbook on port 3000. I want to test this on a couple of phones and looking up the ip of my macbook eachtime i want to test this is turning to be cumbersome. I wanted a way to do access the web application from these phones by using my macbook's hostname .

➜  ~ti git:(release-us) hostname
GM20152.local

➜  ~ti git:(release-us) curl -s   gm20152.local:3000 
<html><body>You are being <a href="http://gm20152.local:3000/subscriptions">redirected</a>.</body></html>%

But when I try this url (http://gm20152.local:3000) from my other devices - which are connected to the same wifi network as the macbook - The browser cant find the server. I guess this is because the android phone that I am trying this on has no way of mapping this name (GM20152.local) to an ip address (my macbook ) . Whats the best way to accomplish this ?

2
  • Can you confirm that it works when you use the IP address of the Macbook rather than the host name?
    – user
    Aug 15, 2014 at 13:44
  • 1
    yes. it works when I use the ip address. I just dont want to look up the ip address everytime.
    – Prasanth
    Aug 20, 2014 at 0:21

3 Answers 3

0

Depending on the router you are using, you could assign a static IP address for your Macbook by identifying your mac address and then use a hosts entry in the mobile phones.

There are applications in the market that allow you to add entries to your hosts table in Android. They would probably need root though... Not sure on that point.

Additionally, some routers can also allow you to define a name for the static IPs and provide DNS resolution for those names within the network. But that would depend on the capabilities of your router.

(I've done that using dd-wrt)

1
1

There are applications and services that streamline the process of exposing a localhost port (or a configured local virtual host) to the internet over HTTP or HTTPS.

One example is ngrok (https://ngrok.com/features) though there are others like localtunnel, pagekite, or forward.

The free features and basic download and usage of ngrok (See: ngrok.com/usage) should allow you to create a tunnel that exposes your local web server via a randomly generated ngrok domain. You will also be able to inspect traffic requests.

Additional features that require sign up include different types of network tunneling, multiple tunnels, password protection of your tunnel(s), and custom subdomains.

Paid features include domain and subdomain reservation - but this and the sign-up features don't appear necessary for your purposes.

If you prefer to manage the tunneling service yourself, you can even run your own ngrok server (Docs: https://github.com/inconshreveable/ngrok/blob/master/docs/SELFHOSTING.md) but again, not necessary for your purposes.

0

Most modern consumer routers handle hostnames fine. The only thing is that your other devices have to be using your router as a DNS server.

A caveat is that the .local domain name is something Macs add automatically. The router may not be using that for resolution, and you may have better luck just connecting to gm20152:3000

Not the answer you're looking for? Browse other questions tagged .