React-native Development Could not connect to Development server (Android) workaround

Source: Internet
Author: User

Write at the front:

Originally, I was having a blog Summary of the bug in RN development (continuous update) to summarize the various bugs encountered in react-native development and its Solution the solution.

However, because Could not connect to Development server is a super big bug I detest.

Why do you say that?

Because this bug is not easy to find a solution online. This bug is true on the Internet, but most of it is a solution to iOS development, a

some Old outside of the site is also discussing this issue, and finally found a point and my problem , and did not give a definite solution, it is really let me Yu

Stuffy, and and this bug bothered me for a long time. Today we will share their solutions to help more netizens.


1, we first look at this big Red screen error bar. :



To translate first:


The server that is not connected to the development.

Follow these steps to fix this problem:

    • Ensure that the package server is running
    • Make sure your device or simulator is connected to your computer, and your phone has USB debug mode turned on, then run ADB devices in CMD to see a list of connected devices
    • Make sure the flight mode is off
    • If you are using a real machine to develop, enter ADB reverse tcp:8081 tcp:8081 to check the device
    • Enter ip:8081 (this everyone will)



Workaround:


1, first check whether the package server is running properly.

Enter react-native start or NPM start in the project folder to open the server, but we need to verify that the package server is functioning properly on the PC side. Check the URL: http://localhost:8081/index.android.bundle?platform=android


(1) to talk about the problem I encountered, after opening the package server, CMD appears as follows:


The appearance of React Packager ready will not move.

When I see the http://localhost:8081/index.android.bundle?platform=android URL, there is no normal display, but there is no

have a Show "This page cannot be accessed", but has been in the circle to refresh the page, is not open.


Now I have my own problem (no wonder I used to enter ip:8081 and didn't have any birds)


How to solve?


A: After my observation, the package server uses node, so it should have a certain relationship with node version and configuration. So I'm going to unload it.

node, reinstall the latest version of node, and then the package server opens, and the Web page can be accessed normally, as follows:



2, check the hardware connection, and use ADB devices to see if the connection is successful.

3, flight mode off

4, enter the ADB reverse tcp:8081 tcp:8081 in cmd, the result is as follows:



When I saw error:closed I guessed that my problem was here. What do we do?


Personally, the solution is as follows:

    • Mobile-settings-application-development-USB debug open and close once

    • Restart the phone, USB debugging open and then close once

    • Under cmd try "adb kill-server" and then "adb start-server"


I test machine for Android 5.0+ system, using the second method to solve the problem. The results are as follows:




5, shake a shake phone choose dev Settings input ip:8081 method is not much to say.


At this point, resolved the could not connect to Development server (Android) problem, my test machine for the charm of blue metal, the system is

Android 5.0+ system, so may and the situation of the small partners are not quite the same, we can refer to the reference. The article is not well written, please forgive me.



If it helps you, remember to praise it.




React-native Development Could not connect to Development server (Android) workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.