localhost:8081: React Native Metro, Expo and alt HTTP port

localhost:8081 is port 8081 on your own computer, and it's the default port of the React Native Metro bundler and the Expo dev server. It's also the default for Sonatype Nexus Repository and the obvious next choice when an app on 8080 already holds the usual alternative HTTP port. If a React Native build says it can't connect to the development server, Metro on 8081 is what it's looking for.

What runs on port 8081

ToolDefault on 8081?Start command
React Native Metro bundlerYesnpx react-native start
Expo dev serverYesnpx expo start
Sonatype Nexus RepositoryYesService, or docker run -p 8081:8081 sonatype/nexus3
mongo-expressYesdocker run -p 8081:8081 mongo-express
Second web serverBy conventionWhen 8080 is busy

Metro is a JavaScript bundler, not a web app. Opening http://localhost:8081/status returns packager-status:running when it's healthy.

Fix "could not connect to development server"

  1. Is Metro running? npx react-native run-android normally starts it in a separate window. If that window closed, start it yourself with npx react-native start.
  2. Android: map the port. On the emulator or a USB device, localhost means the phone, not your computer. Forward it:
    adb reverse tcp:8081 tcp:8081
    

    The standard Android emulator can also reach your machine at 10.0.2.2:8081.
  3. Physical device on Wi-Fi. Phone and computer must be on the same network, and the firewall must allow 8081. In the React Native dev menu set Debug server host & port to YOUR-LAN-IP:8081.
  4. iOS simulator. It shares your Mac's network, so localhost:8081 works. If it doesn't, Metro probably isn't running or is on another port.
  5. Stale cache. npx react-native start --reset-cache (or npx expo start -c) after dependency changes.

Find and free a busy port 8081

error listen EADDRINUSE: address already in use :::8081 almost always means a Metro from another project is still running.

# macOS / Linux
lsof -i :8081
kill -9 $(lsof -ti :8081)
# Windows
netstat -ano | findstr :8081
taskkill /PID <pid> /F

On some Windows machines antivirus software has been known to hold 8081. If netstat shows a security product, move Metro instead:

npx react-native start --port 8082
npx react-native run-android --port 8082

Expo uses npx expo start --port 8082.

Open localhost:8081 from another device

For Metro, the device-specific steps above are what you need. For Nexus or another HTTP service on 8081, bind it to 0.0.0.0 and open http://YOUR-LAN-IP:8081 from the other machine. Find the IP with ipconfig getifaddr en0 (macOS), hostname -I (Linux) or ipconfig (Windows).

Share 8081 or receive webhooks

You rarely want Metro on the public internet: it serves your app's source to anyone who asks. Expo has its own --tunnel mode for devices that can't reach your LAN.

What mobile developers usually need publicly is the backend. Payment, subscription and push providers send webhooks to your API, and they can't reach localhost. Forward them to the API's local port:

relay forward --bucket mobile-api http://localhost:3000/webhooks

The bucket has a permanent public URL, so you set it in the provider dashboard once. Each request is delivered and logged for replay. For an HTTP service that does belong on a public URL, such as a staging Nexus or a demo API on 8081:

relay connect --name my-service http://localhost:8081

Frequently asked questions

What is localhost:8081?

localhost:8081 is port 8081 on your own machine. It is the default port of the React Native Metro bundler and the Expo dev server, the default for Sonatype Nexus Repository, and the usual fallback HTTP port when something already occupies 8080.

How do I fix port 8081 already in use in React Native?

Another Metro instance is usually still running. Find it with lsof -i :8081 and stop it with kill -9 PID, or start Metro on another port with npx react-native start --port 8082 and build the app with the matching port.

How does the Android emulator reach Metro on localhost:8081?

Inside the Android emulator, localhost is the emulator itself. Run adb reverse tcp:8081 tcp:8081 so the device's port 8081 is forwarded to your computer, or use the special host address 10.0.2.2, which points to the host machine from the standard emulator.

What does localhost:8081 show in a browser?

With Metro running, http://localhost:8081/status returns packager-status:running. Metro serves JavaScript bundles to the app, not a website.