xip.io + MAMP Pro = Super-Easy Local Network Testing
I’m sure I don’t need to extol the virtues of working locally via MAMP Pro. One thing that has always annoyed me though is that to test on devices other than my main box, I’d have to either upload the files to a server or fiddle with something like DynDNS.
Recently though, I discovered xip.io. It’s a neat little service that takes 99% of the hassle out of viewing your local sites on any other device that’s connected to your network.
How to use it
- First things first, make sure your local server has a fixed IP on your local network. You can do this through the router config options. If you’re not sure how, just search for “[your router make/model] assign IP to computer” or something similar. This isn’t strictly necessary but it will save a lot of hassle down the line if you reboot your router and all the local IPs change.
- OK, so let’s say your server has the local IP address
192.168.0.1, and the local site you want to use with xip.io goes by the hostname
example.local. In MAMP Pro, click on the example.local item under “Hosts”, then click the + button under the “Aliases” box.
- Enter the alias in the form
[hostname].[server IP].xip.io. So in our example, we would enter
example.local.192.168.0.1.xip.io. Leave the box ticked and don’t worry about the drop-down on the right.
- Hit “Apply” and restart the servers to update the config.
- On the network-connected device you want to test, navigate to the alias you just entered, and weep with joy at how easy it was.
That’s it! Bear in mind that anything that relies on the hostname in your code (cookies, for example) will be using the alias rather than the usual local hostname so be prepared to tweak some configs if needed.
Of course, you can still take advantage of the simpicity of xip.io if you dont use MAMP Pro, you’ll just need to set up the alias by hand. Personally though, I think the time saved with Pro is well worth paying a few quid for - it can often be found on those cheap software bundle sites for a hefty discount.
Posted on Friday, 15th February 2013.
Sorry, feedback is now closed on this post, but please feel free to get in touch if you would like to talk about it!