Local host is not comming up on android emulator - node.js

I have been trying to run my app on android emulator and send requests to my node js local host but localhost:3000 is not working in emulator i also tried 10.0.2.2 and 10.0.3.2 im using Andy android Emulator and my server is up on windows localhost:3000 works on windows but nothing works in the emulator what should i do?

Did you try this ?
10.0.2.2:3000
this should work.
if this is not working check that you're server is up and running on port 3000

Finally i found the solution:
first you should run ipconfig command than there is an ip in one of of the adapters that it bring ,in front of the ipv4 ,mine was 192.168.1.4 you should that ip with :3000 then you can access your local host.
I was using Nox app player

Related

NodeJS and React - LAN connection not working

Description
I have a Node server and React App running on my notebook Ubuntu 18.04.
Notebook ip is 10.0.0.101
I tried to connect my desktop to this server on the same network
Desktop ip is 10.0.0.100
Node is running on PORT=3333
React is running on PORT=3000
I can ping my notebook from my desktop but when I try to connect to node using Insomnia or to http://10.0.0.101:3000 from my desktop I cannot reach.
Errors
When try to connect to backend with Insomnia
Error: Couldn't connect to server
When try to connect to app on 10.0.0.101:3000
ERR_CONNECTION_TIMED_OUT
What I've done
I already changed the node listen and specified the port and the ip but it didn't work.
I tried to use my phone as router and connect from my phone to react on my notebook and also didn't work.
I've tried so many things since I can't remember them all.
I'm also creating a react-native app and when I try to connect to my mobile using Expo, it just works using tunnel, but cannot get data from the backend.
Please save me.
Thanks
After making many failed attempts, I realized that the problem was in my notebook.
I checked my firewall and it was disabled and still cannot get acess to my notebook on LAN. But finally I discovered what have to be done
Solution
You have to open the specific port for TCP traffic
Ubuntu:
sudo ufw allow <PORT-NUMBER>/tcp
or for Red Hat Enterprise
firewall-cmd --add-port <PORT-NUMER>/tcp
Reference: Examples of how to open firewall ports

Angular 4 Failed to load resource: net::ERR_CONNECTION_REFUSED

I guess I will start at the start of my application.
I am making a full mean-stack application and I want it to run in docker. To use docker I am using a virtualbox with Ubuntu. When I run my docker-compose, everything is working on localhost:4200. Now I want to open my application on my host machine (Windows 7).
When I go to my application via (ip addres should be kept secret, right?) xxx.xxx.xx.xxx:4200/login the page looks fine, but I get these errors:
I am using Angular cli 1.4.1 with node 8.4.0
Why am I getting these errors and how do I fix them?
My docker-compose
Your server which is listening on port 4200 is listening on your xxx.xxx.xxx.xxx interface (not necessary to hide lan IP, but nevermind...).
Your angular application is running on your host system. the localhost is the localhost of your host system, not the guest. so you have two solutions:
changing your urls inside the angular application to point to xxx.xxx.xxx.xxx:4200 instead of localhost:4200.
Forwarding your 4200 port from your host to your guest system using virtual box :
shutdown guest.
select guest and click on settings
go to the network tab.
click on "advanced"
then select "ports redirections" and bind your host 127.0.0.1:4200 to your guest's 4200 port

Accessing server program on local machine from Android emulator

I'm running a small Java server program on my local machine using a serversocket listening on port 12345.
I want to communicate with the server from android app running in android emulator. Using address 10.0.2.2 and same port I get the following Exception:
java.net.SocketException: Permission denied
I also included the following tags in my manifest:
uses-permission android:name="ANDROID.PERMISSION.ACCESS_NETWORK_STATE"
uses-permission android:name="ANDROID.PERMISSION.INTERNET"
The emulator tries to connect to the server when a button is clicked. It works perfectly when I run the server and client program on my local machine using localhost as the address.
Solved. I just hat do configure the firewall. Adding a new rule allowing incoming connections on given port and address was the way to go.

Can't connect to documentdb emulator in virtualbox

I am trying to setup a DocumentDB emulator on my Win7 local, then found out it only supports Windows 10.
then I installed the emulator on Windows10 VirtualBox, I have no problem seeing the Emulator page using localhost.
however, when I try to connect from my Win7 local box to the emulator on Win10 virtualbox, I can't get a connection (either from browser pointing to https://localhost:8081/... or from code).
Is the DocumentDB Emulator only accessible from the machine running it?
i turned off windows firewall on Win10
I ran Emulator on port 443 on Win10
Virtualbox network config: NAT Port forwarding 8081 to 443 (i have similar config for SSH from Win7 to Linux VB that works)
thanks in advance
I had the same problem, this is how I succeeded.
First, install DocumentDBEmulatorCertificate from your VM to the host, as a trusted certificate. Here you can find how to export it.
Then forward a port to 8081 with netsh:
netsh interface portproxy add v4tov4 listenport=64000 connectport=8081 connectaddress=127.0.0.1

Unable to connect to cloud9 over LAN

I've installed cloud 9 Ubuntu 14.04 (Desktop), and executed it by typing:
node [cloud9folder]/server.js -p 8080 -a :
I was able to connect to it by typing localhost:8080 (On the same computer that is running cloud 9) but when I went on another computer on the same network, I was unable to connect by typing [ip address of the computer running cloud9]:8080 into the browser. The browser returned: "Webpage not available (ERR_CONNECTION_REFUSED)."
I know the server computer is working, I was able to access it's apache2 website but for some reason it is unable to connect to cloud 9.
How do I fix this?
also add -l 0.0.0.0 by default server is listening on 127.0.0.1 which is not public

Resources