0

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?

4 Answers 4

1

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
Sign up to request clarification or add additional context in comments.

5 Comments

Ngrok works but seems to take too long to load. Took 1.5mins to load a single text in flutter.
Indeed it's slow for me too, using the --region flag might help. For example if you are in the eu: ngrok http -region=eu 5050. Don't get your hopes up though, I've having trouble on my end
I already used the --region flag as eu since I'm inside the eu but its still slow for me.
Hey, I don't know if you receive a notification upon response modification so I'm telling you here: I recently tried cloudflare instead of ngrok and it seems to work well enough to be usable. Not perfect but usable at least.
The question was asking how to configure the server to accept connections over a local network. ngrok/Cloudflare create a tunnel to allow the server to be accessed over the Internet, while this does work it's not an efficient way of doing it, I'll add an answer if I find a way to do it properly
1

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.

Comments

1

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

Comments

0

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).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.