1

Hi i just first time created a project i VS code using react native command npx react-native init Projec. i folow the instructions i need to open in in an emulator in android studio but it wont work bcs when i start the app npx react-native start. i get an arror screenshoot down.

PS C:\Users\Stefan\Desktop\Teast\Test> npx react-native start

               ######                ######
             ###     ####        ####     ###
            ##          ###    ###          ##
            ##             ####             ##
            ##             ####             ##
            ##           ##    ##           ##
            ##         ###      ###         ##
             ##  ########################  ##
          ######    ###            ###    ######
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######
             ##  ########################  ##
            ##         ###      ###         ##
            ##           ##    ##           ##
            ##             ####             ##
            ##             ####             ##
            ##          ###    ###          ##
             ###     ####        ####     ###
               ######                ######

error listen EADDRINUSE: address already in use :::8081. Run CLI with --verbose flag for more details.   
Error: listen EADDRINUSE: address already in use :::8081
    at Server.setupListenHandle [as _listen2] (net.js:1316:16)
    at listenInCluster (net.js:1364:12)
    at Server.listen (net.js:1450:7)
    at C:\Users\Stefan\Desktop\Teast\Test\node_modules\metro\src\index.js:235:20
    at new Promise (<anonymous>)
    at Object.<anonymous> (C:\Users\Stefan\Desktop\Teast\Test\node_modules\metro\src\index.js:234:14)    
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\Stefan\Desktop\Teast\Test\node_modules\metro\src\index.js:46:24)     
    at _next (C:\Users\Stefan\Desktop\Teast\Test\node_modules\metro\src\index.js:66:9)
PS C:\Users\Stefan\Desktop\Teast\Test> 

Thanks in advance!

Mod3rnx
  • 828
  • 1
  • 10
  • 21
Stefan
  • 69
  • 2
  • 6

5 Answers5

3

You can try this soultuion, it worked for me for the last times, seems like universal(not always) solution.

kill -9 $(lsof -t -i:8081)

Similar stack of this problem

Mod3rnx
  • 828
  • 1
  • 10
  • 21
0

Basically what it means is there is another app occupying port 8081, so you have 2 options.

  1. Kill any apps that runs on port 8081

  2. Start your react native apps on different port

npx react-native start --port 9988
Isaac
  • 12,042
  • 16
  • 52
  • 116
0

We need to transfer port from the emulators after that we can run it:-

step 1. take help of this article t.e. how can we forward emulator app in specific port (https://medium.com/@hsuastegui/use-react-native-in-a-different-port-1109db5674d8)

step.2 run this cmd on terminal: npx react-native start --port 9988 (9988 it's your forwarded port)

0

On Windows:

netstat -ano | findstr :8081
taskkill /PID <HereGoesPID> /F

Then run metro again

npx react-native start
0

For windows (React Native CLI), first find the port, run this command.

 netstat -ano|findstr "PID :3000"

After that,to kill the port, run this

taskkill /pid 18264 /f

Here pid is your PID address which you will find after executing first command.