Reputation: 407
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
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
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
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
Reputation: 3594
Cloudflare should enable you to make a tunnel to your localhost.
On linux you can:
cloudflared tunnel --url http://localhost:5000/
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.
You should look into something like ngrok.
On linux you can:
sudo apt install ngrok
ngrok http 5000
Upvotes: 1