Could not connect to development server

There might happen you'll see red screen with caption "Could not connect to development server" and a list of possible ways to fix an issue.

You might not understand what these obscure help messages means. Let's figure this out.

If you want just to get receipt how to fix this error, run this command

react-native start

from terminal and, if required, reload application.

You may run other command to run application, which will include required step fixing this issue

react-native run-android

When you run application with command

react-native run-android

the following steps happen:

  1. Start JS server (written on Node.js technology)

  2. Application is built

  3. Application is installed onto device or emulator

First step is hidden behind message "Starting JS server..." which you can see on the screenshot below.

Started Node.js server is responsible for communicating with your Android device or emulator and is listening on 8081 port. You can check this by running the following command.

netstat -ltnp | grep -w ':8081'

So, if you accidentally or by purpose kill this Node.js server listening on 8081 port you'll immediately get above red screen.

To fix this issue you should kick off the server again by running command

react-native start

or by running full blown three-step process, including required step

react-native run-android

‚Äč