How send request from react native to local server - reactjs

I am using android emulator and when i send request to localhost it gives me error. I have tried the forwarding the port also ngrok but none of them worked for me. It always gives me error.
[Error:Network Error].

IN Emulator go to setting->click on Network and Internet ->then select Internet->select available network and then re-run your project and check it will work

Please try http://10.0.2.2:8080 instead of localhost:8080. If you are referring your localhost on your system from the Android emulator then you have to use http://10.0.2.2:8080/ Because Android emulator runs in a Virtual Machine therefore here 127.0.0.1 or localhost will be emulator's own loopback address.
Original Answer Source

Related

Could Not Connect my react app via ip4 address

This is my first time making react project.
After I run my project with npm run start, I can connect to it via localhost:3000 and 127.0.0.1:3000 without any problem.
But when I try to connect it with my LAN address on the same computer it shows
Could Not Connect
Description: Could not connect to the requested server host.
It also shown an error on browser console.
Failed to load resource: the server responded with a status of 502 (internal error - server connection terminated)
This same project can be open via ip4 if I run it on my laptop. I can even open it from my mobile in the same wifi.
My computer is own by company so I think something might block it.
Please give me your suggestions on how to fix this problem. What could possibly cause this problem.
Any insight would be helpful.
Thank you.
Run HOST=0.0.0.0 npm run start
Check your IP. <your-ip>:3000 would work.
https://create-react-app.dev/docs/advanced-configuration/ for setting HOST environment variables.

Unable to reach json server from fetch in react native app

I am unable to fetch data from JSON server using the fetch method even I am using the IP address in URL (http://192.168.1.121:3001/).
Its showing error "Network request failed" when I am trying to fetch using react native app but I can access the server using "http://localhost:3001/" in my browser.
I searched a lot on google, everyone is saying use an IP address instead of localhost, I tried this too but still no response from the server.
Please help me to sort it out it would be great for me.
Thankx!
I solved it out by starting my server by providing IP to it...
json-server --watch db.json -p 3001 -d 2000 --host 192.168.1.121
Are you using the IP Address of your PC? it has to be the IP Address from your Pc where you are developing your App - if you are running it on an Emulator. Check your Network Config on your PC and take the IPV4 Address and try that.

Moodle unable to access using domainName

Installing MOODLE_33_STABLE origin/MOODLE_33_STABLE on Ubuntu 16.04.2
I am able to install it and , access it with my vm's ip,
but when i try to change
$CFG->wwwroot = 'http://ipaddress'
to
$CFG->wwwroot = 'http://somerandomname.com'
in config.php,
i am unable to access it using somerandomname.com in my lan.
i have also mapped the vm ip in hosts file of both apache2 and of the other systems in lan, still it shows HTTP ERROR 502, in chrome.
and Host not found when i check the chrome console.
if i am missing something guide me.
i want to access the moodle installed on my VM across my local connection with some domainname rather than the IP .
Thank you.
Sounds like you have to try classical debugging:
Try to access your moodle instance on the specific port, using eg. telnet
telnet somerandomname.com 80
Delete browser cache or open the URL in your incognito mode
Check the apache error log on Ubuntu: /var/log/apache2/error.log.
Check out further possibilities which are causing this 502 error:
https://www.lifewire.com/502-bad-gateway-error-explained-2622939

hosting on webpack dev server accessing from parallels

I am working on an app that for testing is hosted on web pack dev server.
I am using the following settings in my web pack.config file
devServer: {
host: 'mysite.local.co.uk',
port: '14500'
}
I have the following set in my hosts file on Mac
0.0.0.0 mysite.local.co.uk
I can now access the site on my Mac using http://mysite.local.co.uk:14500
I am trying to use a similar config to access the site from a windows 7 parallels desktop I have created.
I have done the following:
Set parallels network to shared
Set the hosts file windows to
[My Mac IP] mysite.local.co.uk
When I attempt to access the site from parallels I get no response
I have pinged [My Mac IP] and get reply's as would be expected.
I have tried setting host to 0.0.0.0 and as suggested here Github Issue
I am at a loss for how to make this work any suggestions would be greatly accepted
On macOS Mojave, go to Settings -> Sharing to see your Mac's network name.
It should say something like "Computers on your local network can access your computer at: YourComputerName.local". You can also change this name to something easier to remember and type.
On my Mac, this allows me to access my dev server via Parallels, Windows 10 and Chrome over port 8080. Not sure if the port matters.

Cannot access Jenkins

I have installed Jenkins on my Ubuntu 12.04 desktop machine using this guide:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
I also needed to follow this guide:
http://aslamnajeebdeen.com/blog/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu
From my other machine (mac laptop) I now try to access Jenkins through safari:
http://192.168.1.100/jenkins
where 192.168.1.100 is the ip address of my desktop machine but I get an Error 404. I have also tried:
http://jenkins
but nothing happens. What am I missing?
The Jenkins service is running on my desktop PC:
service jenkins status
...
Jenkins Continuous Integration Server is running with the pid 3713
And if I enter: localhost:8080 in a browser on my desktop pc I get the jenkins web interface.
PROBLEM SOLVED:
I have followed this guide:
http://www.zzorn.net/2009/11/setting-up-hudson-on-port-80-on-debian.html
and it now works.
I had the same problem but not using Apache, rather only Jenkins on Ubuntu
I solved it by replacing HTTP_HOST=127.0.0.1 with HTTP_HOST=0.0.0.0 on /etc/default/jenkins
Jenkins is set to listen on port 8080 by default,
so you should point your browser to:
http://localhost:8080/
(or, in your case: http://192.168.1.100:8080/ )
EDIT:
If still not able to connect, you may wish to check your firewall settings.

Resources