DEV Community

Cover image for How to access your localhost application on any device
Guga Cavalieri
Guga Cavalieri

Posted on

18 5

How to access your localhost application on any device

I have always had problems while trying to test my applications on my localhost machine. The process was so painful that I would have to do some crazy port forwarding on my router (yes, using my internet provider public IP) or even deploy to staging environment server and access it on the desired device (sadly I did it once 😢).

This was until the other day when my coworker (many thanks to Tays) came to me with a magical solution called ngrok. In a nutshell, ngrok exposes local servers behind NATs and firewalls to the public internet over secure tunnels.

Alt Text

What?? I didn’t catch a thing there!

So, all it does, it takes a port on your computer and forwards it to ngrok’s server. This port is linked to a public URL that can be accessed anywhere in the world by any device!

Wait! Isn’t it dangerous to do that?

Well, we should be safe if we stick to only testing APIs and debugging web apps. We can deploy any application/API on our localhost, expose it using ngrok and then turn it off. And for those who are really worried about security, ngrok has an option to create a password protected tunnel. On top of that, every tunnel is secured through the HTTPS protocol.

My favourite use cases (so far) ❤:

  • Test Web Apps using My Phone before deploying any code to the server
  • Debug OAuth integrations with external services
  • Many more! ❤

Sentry mobile image

App store rankings love fast apps - mobile vitals can help you get there

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read full post →

Top comments (3)

Collapse
 
devhammed profile image
Hammed Oyedele

Can you write something on this?

Collapse
 
mrtung profile image
Mr Tùng

OR using vhost + DDNS

Collapse
 
gugacavalieri profile image
Guga Cavalieri

Nice one Vitali, didn't know this one :)

Probably gonna check it out

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay