Getting connectException: failed to connect to localhost/127.0.0.1

I have formatted my android phone - this was working before perfectly.
I have my code in my mac book - and I do "yarn run build && concurrently “yarn run watch” “yarn run start”
on the expo app version 2.6.4 on Android phone version 6.0.1

I get error on expo app: java.net.ConnectException failed to connect to localhost/127.0.0.1:19000 after I scan QR code.
I saw solutions online, but are mainly with windows or disabling firewall - I am unable to find same options in my kind of setup. Please help

Hi @chaudharynitesh!

When you run the yarn run start, what is the URL that Expo prints out to use (right under the QR code)?

For me, for example it’s:

[09:50:41] Your URL is: exp://192.168.83.210:19000

If your URL is something like 127.0.0.1, try running yarn run start with --lan option and then scan the QR code (run exp start --help to see other options):

    -m, --host [mode]     tunnel (default), lan, localhost. Type of host to use. "tunnel" allows you to view your link on other networks
    --tunnel              Same as --host tunnel
    --lan                 Same as --host lan
    --localhost           Same as --host localhost

Running the packager with --lan option makes the packager use not 127.0.0.1 (https://en.wikipedia.org/wiki/Localhost), but some other URL that is more likely to be accessible by your phone, if they’re connected to the same network.

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