Visual C++ WinRT FAQ – connecting to localhost

This is probably one of the most frequently asked questions on WinRT in the forums. The answer is – no, you cannot communicate with localhost. You can communicate with a service running on the local network, the intranet, or the internet. But you cannot connect to the loop back address. This is by design. It’s a security measure, and also a side-effect of how a Metro app cannot take any assumptions about the machine it’s running on. And expecting a localhost service to be running is such an assumption. So what’s the alternative? Use the cloud :-)

Note: you can connect to localhost for debugging, but your app will not be approved for publishing to the store.

4 thoughts on “Visual C++ WinRT FAQ – connecting to localhost

  1. It’s not so much a technical limitation as it is a certification constraint. Actually, when you’re developing your app, you’ll notice that you _can_ access localhost (or 127.0.0.1 or 192.168.0.x). But when you try to get your app certified for the Windows Store, they’re going to check that you aren’t implementing an architecture that relies on local services. If you create an enterprise app that you don’t need to publish to the Store for distribution and monetization, you are free to connect to the localhost.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s