Tembero
Tembero

Reputation: 407

Flutter Web: Access development server from another device

I am using Flutter Web and want to setup the development server for multiple devices. I'm currently running the server like this:

flutter run -d web-server --web-port 5000

This works for http://localhost:5000 but when I try to access the server from http://127.0.0.1:5000/ even on the same machine it doesn't work.

How can make the server accessible from any device under the same network without building the app?

Upvotes: 0

Views: 2761

Answers (4)

Alon Dahari
Alon Dahari

Reputation: 1157

You can do so by running flutter on chrome (flutter run -d Chrome) and then pointing ngrok to the port exposed by flutter (check out the url in your chrome browser on your computer).

Upvotes: 0

Tymoteusz Chmielewski
Tymoteusz Chmielewski

Reputation: 171

For me hostname 0.0.0.0 does not work (it works with PHP but not for Flutter)

flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000

It works when using actual local IP number of my machine

Upvotes: 1

Heath Mitchell
Heath Mitchell

Reputation: 372

You need to add --web-hostname 0.0.0.0;

flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000

This tells it to listen on all addresses.

Upvotes: 1

Lulupointu
Lulupointu

Reputation: 3594

NEW ANSWER

Cloudflare should enable you to make a tunnel to your localhost.

On linux you can:

  1. Install Cloudflare
  2. Create a tunnel which point to localhost:5000 with cloudflared tunnel --url http://localhost:5000/
  3. Use the given address to access your local development website from anywhere

Note that this is still slow. I would say it's good enough if you need to check on other devices once in a while but not if you want to develop like you would with hot reload.

OLD ANSWER (This seem to be really slow for an unknown reason)

You should look into something like ngrok.

On linux you can:

  1. Install ngrok: sudo apt install ngrok
  2. Create a tunnel which point to localhost:5000 with ngrok http 5000
  3. Use the given address to access your local development website from anywhere

Upvotes: 1

Related Questions