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.
Related
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
I have a server running on localhost:5000 on my desktop, and when I make http requests through my react-native app when running on the iOS simulation to it, it works. However, when I connect to a real device, the http requests don't work. What am I doing wrong? Is there something I have to configure?
localhost in your desktop is not the same ip of the localhost of your device.
Get the ip of your computer by typing ifconfig in a terminal, then replace localhost by this ip, you should type something like that in your device browser:
192.168.0.23:5000
Maybe my answer is too late but I ran into a similar situation today and I got it to work by running my node server using the IPv4 of my desktop and then making the request to that IP.
For example, I am running my nodejs development server at http://192.168.0.135:3000(local IP of my desktop) instead of localhost and then I make the fetch API request from my react-native app to http://192.168.0.135:3000/.
Just make sure your nodejs server and your app are on the same local network. My react-native server (metro bundler) is running on a separate PC also in the same wifi network.
If your are on macOS go to settings -> Wifi / and show more,
on bottom you see "IP address", it's your correct localhost for ios physical device !
I have a working bot that interacts normally with the bot emulator.When I added docker support the emulator stopped interacting with the bot.
I read that I should un check the "bypass ngrok for local addresses" in the emulator settings and configure ngrok.
I have trouble understanding what I should do, I downloaded ngrok.exe and it opened a command line under the name "ngrok.exe".
The path for the running project is :"http://localhost:32768/api/messages".
How should I configure ngrok so the emulator will start interacting with the bot ?
Any other approaches would be good to..
I was able to get my docker container to work with my emulator finally, so I'll show you what I had to change to get it to work!
Using: Emulator 4.2.1, ngrok, and a sample echo bot:
Place the ngrok.exe file where you can find it. Mine's in a folder on my desktop. Then open the emulator. In the bottom left, there is a cog wheel for the emulator settings:
That page will open ... emulator settings. In this page, use the browse button to navigate to and select your ngrok.exe file:
I found that it did not matter for me whether or not I checked the 'Bypass' box.
Note (here's what saved me): localhost is mapped to my ipv4
I ran ipconfig /all in my command prompt to get my IPv4, and then went back to the emulator. In the configuration for my bot, where I was supposed to put in my end point (typically https://localhost:3978/api/messages), I replaced the word 'localhost' with my IPv4:
After I did that, I was able to talk to my bot:
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.
Hi, I'd like to run my gwt project in dev mode and open it on my i pad. How can I do this? I tried to replace the local-host part with my pcs ip address and open the website, but it doesn't work.
If you are using eclipse, the Jetty server binds on the localhost interface only, meaning that it will not serve request when the address is not localhost even if the specified IP is on the same machine. To allow connection from other computers (or iPads) you need to modify this addres in the launch configuration.
Open your launch configuration:
Run --> Run Configurations... --> Web Application --> [YourApplication]
Open the Arguments tab and in the first text box (Program arguments) add the following argument:
-bindAddress [your ip address]
ex: -bindAddress 192.168.1.200
see this post
There is NO WAY to use the dev mode for iOs, because there is no dev-mode plugin for iOS.
You can enable the Super Dev Mode. This will enable a really fast compiler.
update
As mentioned: -bindAddress 0.0.0.0 may be helpful to bind the jetty to any IP.
Your ipad and the system must be connected via Network (LAN).