Could not connect to development server. Error while running - ios

I have tried to restart the server with npm start, npx react-native run-ios, npx react-native start. Those commands don't work for me. Help me out to run this project its a project created with npx react native init projectName.
warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
The error shown on the emulator

Run adb reverse tcp:8081 tcp:8081 in your terminal then reload in the terminal after running yarn start or npm start, then reload. I hope this is helpful.

I had the same problem and spent hours working on it. I figured out that METRO which is run using this command: npm start or this one npx react-native start couldn't find its way to my mobile app.
one of the solutions that I wasn't totally pleased of was this: a solution that works but has flows
but that workaround wasn't perfect because I had to re-run the command every single time I make a change. So after further researches I found out that the port 8081 is used by an another application that METRO is sending information to ( this is only my guess ). so:
I run the following:
netstat -aon | findstr 8081 // to get the PID of the application that is running on 8081 port
I opened task manager ( CRTL + ALT + del ) under the service section I looked up any
application which uses the PID that matches the one given by the command I ran and I have
forced stopping it.
retried npx react-native start and npx react-native run-android on my project
and the magic happened. It auto refreshes with every change, I wish it helps you.

This is from the docs:
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll
first need to install the app on your device using a USB cable, but
once that has been done you can debug wirelessly by following these
instructions. You'll need your development machine's current IP
address before proceeding.
Open a terminal and type /sbin/ifconfig to find your machine's IP address.
Make sure your laptop and your phone are on the same Wi-Fi network.
Open your React Native app on your device.
You'll see a red screen with an error. This is OK. The following
steps will fix that.
Open the in-app Developer menu.
Go to Dev Settings → Debug server host for device.
Type in your machine's IP address and the port of the local dev
server (e.g. 10.0.1.1:8081).
Go back to the Developer menu and select Reload JS

Related

React-Native Could not connect to development server

I've been testing my project on my iPhone6s and it worked perfectly. But today Xcode and Node.js keeps giving me the 'Unable to execute JS call: __fbBatchedBridge is undefined' error.
I'm sure the IP address is correct, my phone is under the same Wifi network with server. The simulator works fine with the server ip. To test if it is something wrong with the project I start another AwesomeProject and changed the IP but still not working. Anyone know any possible solutions?
I faced the same issue in my office Wifi network connection also. This is because of the router configuration. There are two ways to make it work.
Expose the local server using ngrok. But, It will be slow since it is sending everything to server.
Connect your phone using USB cable and type the following command in the computer adb reverce tcp:8081 tcp:8081

Meteor JS Can connect to compose.io on everything except iOS device?

I have been working on an application and using compose.io as my database platform. I am able connect to compose in web browser and iOS simulator with:
MONGO_URL="mongodb://myUsername:myPassword#aws-us-east-1-portal.6.dblayer.com:11111/dbName" meteor (run , run ios)
However when I try the same process with run ios-device --mobile-server, or ios-device --mobile-server -p 127.0.0.1:3000 it just keeps creating a local database instance. In Meteor documentation it says may need developer account, but I am assuming that was outdated as of Xcode 7 testing on your own device was free, unless this does not count for database connections.
Any ideas, is my command line string incorrect, or is a developer account required? Maybe something else.
Thanks!
I was able to solve my issue by disabling my cellular network, so that my mobile device(iPhone) and local machine(Mac) were using the same network(Wifi) guaranteed. Be to delete any exiting instance your Meteor app your device before running the following while the device and local machine are on the same network.
MONGO_URL="mongodb://myUsername:myPassword#aws-us-east-1-portal.6.dblayer.com:11391/dbName" meteor run ios-device

React native not running on localhost

React native stopped working, whenever I run it now (no matter which project) I get the error could not connect to development server |
ensure the following
node server is running and available on the same network - run npm start from react native root.
Node server url is correctly set in appdelegate
URL : http://localhost:8081/index.ios.bundle? platform=ios&dev=false
Please ensure you have done the following
1) run server using
npm start
2) if you are using actual device , make sure you are connected to same network
3) for android: run the following command and try again
adb reverse tcp:8081 tcp:8081
I was face same problem while running in physical device.
I did as below:
Open terminal and check your local ip address.
Shake device(android) click on dev settings
Click "Debug server host & port for device" under debugging
type local ip address and port number.
note: cross check in browser ip along with port number.
I usually just run npm start in my terminal. (OSX) I assume it would be the same on Windows
npm start
To debug on a real device:
On iOS - open the file AppDelegate.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
let jsCodeLocation = NSURL(string: "http://{{YOUR IP ADRESS}}:8081/index.bundle?platform=ios")
On Android, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

Error when testing app from mobile device - ERR_CONNECTION_REFUSED

After upgrading to OSX Yosemite, I can no longer test my app on a mobile device by using my development machine's (MacBook Pro) IP address. For example, I used to be able to view a Rails app on a phone by going to http://192.168.0.4:3000, but now I get the following error:
ERR_CONNECTION_REFUSED
I get the same error when testing an AngularJS app using the grunt server running at http://192.168.0.4:9000
Any help will be greatly appreciated.
It could help to bind the server to your local IP, like
rails s -p9000 -b192.168.0.4
to start your rails app
Consider giving a try to Pow. Its pretty simple to install, and a great solution to share a local development across multiple devices.
Like it explains in their homepage, you can install it with just :
curl get.pow.cx | sh. To prevent any errors, install in Terminal app outside a Tmux session.
And just symlink your app :
cd ~/.pow
ln -s /path/to/myapp
You can access your app at http://myapp.dev/, and at http://myapp.[your ip address].xip.io from another device.
Not a direct response to your issue, but an alternative to setting yourself a configuration in your preferences.
Turn IPv6 off. It Prevented me from connecting to my localhost from other computers on my LAN. And, with the newer versions of OSX there is no way to turn it off in the Network Preferences Panel so you have to do it from terminal.
Open Terminal and enter to turn it off:
networksetup -setv6off Wi-Fi
And this to turn it back on:
networksetup -setv6LinkLocal Wi-Fi
If you are connected via Ethernet or something else just run this command to list the available options:
networksetup -listallnetworkservices
and replace "Wi-Fi" with the appropriate device.
I don't have a mac, but that seems to be the server not accepting connections, if that is the case, it's only accepting localhost connections, try binding de server to accept all connections or bind it to 0.0.0.0 ip
Can you access that IP from Browser? are you sure your IP is in the same range with 192.168.0.4? It is your mobile device connected on the same network? Maybe you used internet sharing before update to Yosemite and now is off?
I think your IP address changed. Telnet from console(terminal) your I.P. port. If 192.168.0.4 is your real Ip then maybe add(as root or via sudo) an entry in /etc/host file an entry as 127.0.0.1 192.168.0.4. Restart network or reboot. Also you can try nmap ( on ip to see open ports). Nmap has been ported to OSX just google for installer.

meteor cordova build vs production server (no hot code push)

can't get my head around hot code push in my setup:
on server A (osx with xcode and add-platform ios) i built a meteor cordova app with
meteor run ios-device --mobile-server https://productionserver.com
(when i point my cordova app at my localhost:3000 hot code push is working just fine).
on server B (linux, nginx, some meteor instances on port 808x) i run
meteor --port=127.0.0.1:8080
server B runs without add-platform ios (linux), but i found an interesting discussion from slava here and did:
meteor add-platform firefoxos
and thought that hot code push would trigger with this stub.
when i change the code (client directory) on server B, the change is reflected when i call the web interface.
But in my cordova app no change is happening even after app restart.
can you please point me in the right direction?
how is the code push happening behind the scenes?
how should i set up my build/prod environment the make hot code push working?
thanks for your help
I got my app working. The problem was that I had removed android from the platforms list. I'm guessing you still have ios in your platforms.
Your Meteor setup strikes me as a little odd:
1. you say you have multiple Meteor instances on port 8080?
2. Also starting Meteor on a specific port uses command meteor --port 8080 and not the IP.
3. Does the app actually connect to the server? As in databases get synced and new information gets sent across?

Resources