React-native: Connection refused when running android project

Created on 30 May 2018  路  8Comments  路  Source: facebook/react-native

Environment

OS: Windows 7
Node: 8.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

Description

Connection refused while running react-native run-android

Steps to Reproduce


react-native run-android

Expected Behavior


Build success

Actual Behavior

to: java.net.ConnectException: Connection refused: connect to: java.net.ConnectException: Connection refused: connect

Android Locked

Most helpful comment

It's due to fact that Win7 prefers to return IPV6 address for localhost and mine was not properly setup. So I forced java to use IPV4 adress by adding a new environment variable :
_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true
And it fixed it.

in what file?

cd your project file and paste it to terminal
for mac: export _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true

All 8 comments

It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Any solution for this issue?

Any solution on this? im having the same problem, I suspect it was something to do with realm? since the port is 5037 and im seeing this piece of message when react-native run-android.

Task :realm:forwardDebugPort

  • daemon not running; starting now at tcp:5037
  • daemon started successfully

It's due to fact that Win7 prefers to return IPV6 address for localhost and mine was not properly setup. So I forced java to use IPV4 adress by adding a new environment variable :

_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true

And it fixed it.

i have same issue.
i use macOS High Sierra 10.13.6 and react-native version: 0.57.7

It's due to fact that Win7 prefers to return IPV6 address for localhost and mine was not properly setup. So I forced java to use IPV4 adress by adding a new environment variable :

_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true

And it fixed it.

in what file?

It's due to fact that Win7 prefers to return IPV6 address for localhost and mine was not properly setup. So I forced java to use IPV4 adress by adding a new environment variable :
_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true
And it fixed it.

in what file?

cd your project file and paste it to terminal
for mac: export _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true

Thank you @minhphung210

Was this page helpful?
0 / 5 - 0 ratings