Expo using 127.0.0.1 on LAN connection

I updated my expo-cli to 3.28.0 and after that when I start the metro server it shows my LAN address as 127.0.0.1
Anyone solved this issue?
Working with tunnel is not that good and I’m facing tunnel connection instability as well.

hi there. nothing changed that would impact this between versions. try rebooting your computer maybe. or starting explicitly with expo start --host lan

1 Like

I rebooted, reinstalled LAN driver, used wifi, also tried the --host option and still was using 127.0.0.1 as IP address on LAN connection. I’ll try to uninstall and reinstall expo-cli.

are you running expo-cli inside of a docker container or some other virtualized environment?

1 Like

Nope. Running on my machine. I have genymotion and virtualbox installed, but i’m using on my PC. Tried also disabling VBox network interfaces, and it still is getting 127.0.0.1 on my lan connection.

you could try rolling back to an older version of expo-cli to see if that changes things. it would be good to know, but i doubt it will have an impact.

the most recent related commit was a year ago, in october 2019: fix(xdl): detect LAN IP from default gateway (#1096) · expo/expo-cli@d012ae3 · GitHub

you could try installing internal-ip in a new node project and then importing it and seeing what internalIp.v4.sync() gives you. we’re currently using “internal-ip@4.3.0”

1 Like

I’m trying to do that. But seems that I’m not capable of doing it.
Created a new node project, installed internal-ip, created a index.js with the code below. Tried node index.js but it didn’t work…
Code:

import internalIp from 'internal-ip';

console.log(internalIp.v4.sync());

I get this error:
(node:2504) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
D:\Projetos\teste\index.js:1
import internalIp from ‘internal-ip’;
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:931:16)
at Module._compile (internal/modules/cjs/loader.js:979:27)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47

use require instead:

const internalIp = require('internal-ip');

console.log(internalIp.v4.sync());
1 Like

It is returning undefined. Maybe that’s the problem…
Expo might not have been able to get my IP address and is throwing a localhost default…

New problem is: what happened since last time i used expo? :frowning:

I’m lost.

interesting… definitely something happened on your machine. sorry i’m not very familiar with windows so there isn’t much i can do to help resolve the underlying issue. but i might be able to help you work around it - you could try setting the environment variable REACT_NATIVE_PACKAGER_HOSTNAME to your network ip address

1 Like

i run a set REACT_NATIVE_PACKAGER_HOSTNAME=‘MYIP’ on my console on my project dir?

i think so, i’m not familiar with environment variables on windows or how to use windows beyond playing video games :slight_smile:

1 Like

In case you don’t know how to set the environment variable globally and permanently you can do it by following the instructions from this article:

It talks mainly about the PATH variable, but the same procedure works for other variables.

1 Like

I think that it might have something going on my cable modem. The provider won’t let me access it. It has wifi built in. And it seems that the wifi network and lan networtk are not “talking with each other” though they appear to be under the same dhcp server. I’ll try to contact the provider. But i think they won’t have much help to offer. Never met a suport technician that really have technical knowledge. They follow scripts.

Oh, and i’ve set the sys var manually and when the server started, showed localhost on bash, but on metro server it showed my manually set IP. Even so, my cellphone wouldn’t connect to the server.

Ah yes, it is possible that the wifi AP is configured not to allow the clients from seeing each other or machines with an ethernet cable.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.