I've tried from all Stack Overflow's existing answer for this topic but they're not working for me. I've tried using http proxy with Squidman, created local network between my iPhone and my mac with static IP, then accessing it using my machine IP address. I've also tried ping my mac using my Windows pc, it can't ping to my mac but my Mac can ping my Windows, both firewall are disabled.
Any configuration that I missed?
if your desktop is (192.168.0.101), you need to run your service as 0.0.0.0:8080 (example port). Usually ports are bound to 127.0.0.1
This way your router can direct requests from 192.168.0.101:8080 to your application. Ensure you undo this in case you exposing sensitive data.
Assuming your mac ip is $ip, you can do the following to make port $port accessible from your local network:
$ ssh -R $ip:$port:localhost:$port localhost
It will relay all requests from $ip:$port to the localhost server.
Example:
$ ssh -R 172.16.0.111:3000:localhost:3000 localhost
(Posted on behalf of the OP)
The main problem that causes my Mac can't be accessed by other device is the firewall blocked ICMP. Then I disabled it using this command below:
pfctl -d
My firewall rules list:
Related
I'm using docker inside VirtualBox (Ubuntu Server 20.04), since I cannot use Docker Desktop in the host (Windows 10).
I have a docker nodejs container on port 3000. In my host I can access it through 192.168.56.110:3000, where 192.168.56.110 is the IP address of the VM but I need to access it through localhost:3000.
The setup is of course similar to a docker-toolbox installation (as in this question), for which I've found that the host localhost also does not work, to put it simple.
I've tried to map localhost in Windows 10, as suggested in a few answers like this one adding to C:\Windows\System32\Drivers\etc\hosts:
192.168.56.110 localhost
192.168.56.110 dev.com
But while dev.com works right away as expected, localhost doesn't.
Is there a workaround?
When I run an Angular development server in the guest, I can access it via localhost:4200 from the host but it is not completely clear to me what happens behind the scenes. Side question, how does ng serve lead to the "redirection" of localhost in the host OS?
Run as administor a windows command prompt and enter:
netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=3000 connectaddress=<replace with docker ip address> connectport=3000
To confirm, run
netsh interface portproxy show all
Good luck.
Hello sorry for stupid question.. But i have googled it for a week and still can't find the answer.
Currently I'm using Virtualbox for ubuntu server 18.04 and I have installed docker on it. I have run docker apache server by using sudo docker pull httpd and sudo docker run -t --name apache -p 8080:80 httpd
And there is the problem. I can show the website by using curl 127.0.0.1:8080 but i can't access from the other network or other machine in different network.
For instance my virtualbox's ip address is 1.1.1.1 and host pc which is window is 2.2.2.2.
When i ping to each other it all works. But when i try to access 1.1.1.1:8080 from host pc i can't access
What should i check or do to solve this problem.
Thank you
For "1.1.1.1:8080" access on the host- Try opening TCP traffic on port 8080 of your virtual machine with firewall-cmd or an equivalent Ubuntu utility. "1.1.1.1:8080" should then become available on your host server.
For "2.2.2.2:XXXX" access from other devices on your home network(s)- You might need to both route the port of your VM to a port of your host (unless you have a pass-through NIC configured on the VM) on the VM manager plus open an additional firewall on your host server on the host port you've mapped to for access by other devices on your home network. After those steps on the host port "2.2.2.2:XXXX" should be the web server IP accessible by any device on your network(s).
For PUBLIC_IP:PUBLIC_PORT access from outside networks (external to your modem and available to the world)- IPs on your home networks can't be accessed from other networks. Access from other devices on your network is controlled by your firewall on your OS. Access from outside networks is controlled by port forwarding on your modem. I don't recommend port forwarding for a custom app unless you understand some of the security loopholes that can exist on a development web server. But to manage port forwarding go to http://INTERNAL_IP_OF_YOUR_MODEM and you'll get a management interface for managing your port forwarding settings. You'll also see your public IP on your router's management UI or by googling "my ip address".
You can map your modem's IP to an official www web domain with a web domain service like GoDaddy. You can map your internal IPs to internally known web domains by editing /etc/hosts files on the devices on your network.
I'm trying to run a simple web server on a Raspberry Pi with Flask. When I run my Flask app, it says:
running on http://127.0.0.1:5000/
But when I enter this address on my laptop's in Chrome, I get
ERR_CONNECTION_REFUSED
I can open 127.0.0.1:5000 on the Raspberry Pi's browser. What do I need to do to connect from another computer?
Run your app like this:
if __name__ == '__main__':
app.run(host='0.0.0.0')
It will make the server externally visible. If the IP address of the machine is 192.168.X.X then, from the same network you can access it in 5000 port. Like, http://192.168.X.X:5000
when you are running the server via flask run change it to flask run --host=0.0.0.0
to connect, find the IPV4 address of the server that your script is running on. On the same network, go to http://[IPV4 address]:5000
A reason could also be in firewall refusing incoming connections on port 5000. Try:
sudo ufw allow 5000
app.run(host='0.0.0.0',port=5000)
if you run your app in this way then your server will be visible externally.
Steps by Setp:
Run your app by using the following command
app.run(host='0.0.0.0',port=5000)
Go to the window cmd . Type ipconfig and get the get the IPV4 adress suppose your IPV4 address is 192.168.X.X
Go to the mobile browser and type the 192.168.X.X:5000
If you have debug = True inside your app.run(), then it will not be visible to other machines either. Specify host and port inside app.run() without the debug = True.
You will have to run the development server such that it listens to requests on all interfaces and not just the local one
Ask Flask to listen on 0.0.0.0:PORT_NUMBER
or any other port you may choose
On MacOS 12.4 (Monterey) I couldn't load localhost nor my local IP but it worked with both of these:
0.0.0.0
127.0.0.1
Just change the URL in the browser if it loads with "localhost".
Both devices must be connected to same network.
Use app.run(host='0.0.0.0',port=5000) and run with your own Ipv4
address like his http://[Your Ipv4 address]:5000
If you are connecting this with android app then don't forget to
put INTERNET permission in manifest file.
Contrary to popular believe 127.0.0.1 is not the same a localhost.
I solved the issue above by setting 127.0.0.1 explicitly on both ends.
Well i was also here to know answer but i guess i found out problem. The reason is that you may not activated or run flask that's why it is showing error. For that you have to start from terminal "flask run" and then surely your flask will run...
The issue may occur, if VPN is on, so try to switch it off.
Hello i am trying to access my Webrick rails server that i started on my ubuntu to my windows 7 pc locally. I checked on ifconfig in my virtual box and used the inet:10.0.2.15 when i run my rails server and also used port 80 like this:
rails server -b 10.0.2.15 -p 80
It didn't gave me an error in the terminal but when i try to go to 10.0.2.15 on my windows browser, it says it can't connect. I tried disabling the firewall in windows but still wont work. Thank you.
Choose another network type for your VM ubuntu. I suggest the Bridged Network. Reboot vm, it should obtain ip in same network as your windows host (example 192.168.0.XXX). Then you will be able reach your rails server from network At any port 80 or 3000.
Can you share your ubuntu with the vm, via the apache server too? is that started? In macs you have to enable web sharing (or something similar to that wording). ON ubuntu what happens when you do localhost:80... if i recall it should say it works! or something like that.
I have a Rails site that I'm developing on localhost Ubuntu and I have a mobile.
My site is running on http://localhost:3000.
I want to access this directly via my mobile browser not going through the internet.
Is there any way to access it via WiFi or some other way?
If your computer is accessible from internet, just enter in your mobile browser:
http://your.ip:3000/
You could also create a local network (via wifi for instance), connect to it with your cell phone and then do the same thing.
If you are using Rails 4.2+, start the server using:
rails server -b 0.0.0.0
(see http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server).
1.) get your local ip by typing:
ifconfig |grep inet
into your shell/terminal. your ip usually looks like this: 192.xxx.xxx.xx
2.) then start the rails server with:
rails server -b 0.0.0.0
3.) your application can now be reached by typing:
192.xxx.xxx.xx:3000 into the browser.
Using ngrok
So basically, you run the command
./ngrok http 3000
And you will see the output like that
And all you need is copy the highlight URL and paste to the browser.
Execute
rails s -b IP_ADDRESS
Access mobile: IP_ADDRESS:3000
First find your Ip and note it down by typing ifconfig terminal(you should be connected to wifi or network)
ifconfig
than run the rails server by typing
rails server -b 0.0.0.0 (YOUR IP )
and press Enter
SERVER WILL BE RUNNING ON YOUR_IP:3000
2. Now connect your mobile with the same network and open url
https://YOUR_IP:3000
CONGRATS YOU ARE RUNNING LOCALHOST ON MOBILE
On rails-server machine:
Make sure you're running rails-server.
Get your IP address, I got "192.168.1.112" for example.
On mobile:
Access through browser by using:
http://<your_ip_address>:3000
http://192.168.1.112:3000
NOTE: Your mobiles need to have the same network with rails-server machine.
To get yourself IP address, run this command in your rails-server machine.
MacOS or Linux Terminal:
ipconfig getifaddr en0 || ipconfig getifaddr en1
# => 192.168.1.112
Description:
ipconfig getifaddr en0 is for wifi connections
ipconfig getifaddr en1 is for wired connections
Windows:
ipconfig
Then looking for IPv4 Address.
Running rails-server
On rails-server machine, it's okay to regularly run:
bin/rails s
If you found issue, you can try the following:
bin/rails s -b 0.0.0.0
Note: 0.0.0.0 is not an IP address, it's a shortcut for the system binding call to use all available IP addresses including 127.0.0.1, localhost.
Access through http://localhost:3000/
if you get ipconfig command not found on ubuntu
Try:
ip route to get the IP address then you can run rails server as explained in other answers.
rails s -p 3000 -b 192.168.0.102 (Replace IP with your system's IP).
Now you should be able to access on you mobile browser by just entering
http://192.168.0.102:3000/
run your server on 0.0.0.0:port_no rather then 127.0.0.1 or localhost
then check your IP address by typing a command in your terminal
ipconfig
here you can check your host machine's IP address.
-Now we have to enable 3000 in your case port to be accessible in the network
write following commands
sudo ufw enable
sudo ufw enable port_no
sudo ufw status
then you will be able to see your port is enabled
-Now you can access your server in any device browser using IP address:port_no
Check out this picture where I am accessing Django Web App running locally on Ubuntu and I am able to access it on my windows laptop which is in the same network via ip_addess:port_no which in my case is 8000
You can access the same website at