Flutter localhost on real device

Running Flutter app on localhost with a real device

To run a Flutter app on a real device connected to your localhost, you need to follow the steps outlined below:

  1. Ensure that both your computer and the real device are connected to the same network.
  2. Get the IP address of your computer:
  3. <Windows> ipconfig     <Mac/Linux> ifconfig
  4. In your Flutter app code, update the base URL of your API endpoints to use your computer’s IP address instead of “localhost”.
  5. final baseUrl = 'http://your_computer_ip_address:port';
  6. Run the Flutter app using the following command:
  7. flutter run --dart-define=FLUTTER_HTTP_BASE_URL=http://your_computer_ip_address:port
  8. Make sure to replace “your_computer_ip_address” with the IP address you obtained, and “port” with the appropriate port number (e.g., 8080).

Now your Flutter app will be running on your localhost and can be accessed from your real device.


Assuming your computer’s IP address is and you want to use port 8080:

final baseUrl = '';

Then, to run the Flutter app:

flutter run --dart-define=FLUTTER_HTTP_BASE_URL=

Leave a comment