Could Not Connect my react app via ip4 address - reactjs

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.

Related

How send request from react native to local server

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

Node.js application wont start on my public IP

I'm SSHing into a linux shell for a school project. Right now, we're trying to set up a react app for a web frontend. We were able to run the app on localhost easily enough, and all of the functionality seems to be good, but I can't figure out how to get this hosted on the public IP of the computer. We've been using yarn to do all of this, though i've tried other things, so here's some cli output.
path/to/thing# yarn start
yarn run v1.22.5
$ react-scripts start
Attempting to bind to HOST environment variable: public.facing.ip.address //This is a website name
If this was unintentional, check that you haven't mistakenly set it in your shell.
Learn more here: //There was a link here but SO formatting wouln't let me keep it.
Could not find an open port at public.facing.ip.address.
Network error message: listen EADDRNOTAVAIL: address not available public.facing.ip.address //numeric
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
root#computer:path/to/thing#
When I run hostname -I, public.facing.ip.address does not appear at all. So that seems like the obvious issue. The catch here is that we are also running jenkins on a separate port of public.facing.ip.address from this same computer. That was much easier to set up, it just came as something I could start as a service using 'systemctl start jenkins' and up it went onto the public facing IP. I set all that up and I can access it just fine, etc. The best I can do with this is modify the HOST variable either in the terminal or the .env file, then yarn starts a development server on localhost (which I can't access since I'm on a different network SSHing into this computer)
How do I make yarn host our webapp on the public facing IP?
open your router page, there should be dmz host option somewhere, point it to your local ip address
My networking inexperience was the culprit. Instead of using HOST=path.to.public.ip, the solution was to use HOST=0.0.0.0.

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

MEAN app crashed on Internet disconnection

I am developing a MEAN application. When I use localhost for local development the app is running fine on http://localhost:3300 when Internet is there but throws below error when the Internet is disconnected.
process.nextTick(function() { throw err; })
^
Error: getaddrinfo ENOENT
at Object.exports._errnoException (util.js:746:11)
at errnoException (dns.js:49:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
[nodemon] app crashed - waiting for file changes before starting...
Can anyone help me resolving this strange issue? As app is on localhost,it should not have any dependency on Internet.
My MongoDB connection is on mongodb://localhost:27017.
Thanks!
Try changing all localhost occurrences with 127.0.0.1
Had the same problem. Turns out without an active internet connection localhost cannot be resolved into a valid IP.
Make your own local network.
I don't know the exact reason why this is happening. But I noticed that if your pc is not assigned an IP address it will produce this error.
So what I did was, I turned my portable wifi hotspot on and re-run the app and whoa! It worked! That hotspot assigned an IP address to my pc. So, it simply means you should be connected to any network. It can be your mobile hotspot too.

could not connect to local host

Recently i installed apache tomcat 6 on my PC.I started the server and try to open the tomcat manager using the url:
http://localhost:8081/manager/html
8081 is the connector port i used at the time of installation and no other services using this port.But its shows the error like
Oops! Google Chrome could not connect to localhost:8081
I used this with differnt browsers IE and crome but still getting the same error
Please provide me the solving to getrid of this.
Try the "Test your Install" section here.
first make sure the your server is running correctly by connect to http://localhost:8081/

Resources