I'm currently in the process of setting up a web server just for personal and testing use. Right now I'm trying out running some python applications but when I start them, they are ran at 127.0.0.1:5000. Is there anyway I can forward this to make it accessible elsewhere?
4 Answers
As the forwarding part has not been addressed by any of the previous answers yet: you can easily forward local ports using SSH:
ssh user@your.testing.web.server -L 5000:127.0.0.1:5000
This will forward all TCP traffic from port 5000 of your local machine to the localhost-bound port 5000 of your.testing.web.server. The beauty of this setup is that it only allows access for users who are able to authenticate with sshd
and the SSH protocol would encrypt all your traffic.
This of course is not going to help you if you expect your site to be publicly available, but would clearly be my first preference "for personal and testing use".
![](../../users/profiles/76595.webp)
- 40,319
- 13
- 105
- 169
-
Ok, that will help for some testing, but part of what I'm doing is writing some stuff using Twilio. For that, I need to enter my "SMS URL", so that when a number is texted to my Twilio number, it feeds the information to that website. I doubt this solution would work for such a thing. – Breathtender Jan 13 '12 at 17:34
-
As I stated, it would not. In this case, you should rephrase your question to *"how do I bind my network service `
` to my public interface instead of 127.0.0.1?"* – the-wabbit Jan 13 '12 at 17:37
You will need to make the web server listen on all interfaces / network interfaces. Otherwise, it just listens on localhost (127.0.0.10 by default.
You could provide more details about your server / dev environment for more specific help.
![](../../users/profiles/62112.webp)
- 384
- 2
- 8
First you will need an interface and a LAN IP address. Once you have those, you should be able to configure that network on your dev box, then restart your python apps. They will typically listen on all interfaces unless configured otherwise. I'm not a python expert.
Confirm with netstat or lsof.
Then you should be able to connect from another LAN host as the client by entering the LAN IP address from above as the destination.
Beyond that, you'll need some way to connect to the WAN and do some NAT to allow connections from the internet at large.
One final note, check your firewall(s). You may well have a listener going but the firewall is not going to allow port 5000 unless you configure it for such.
![](../../users/profiles/76707.webp)
- 24,720
- 2
- 40
- 69
Thanks everyone for your help, but I found out a way to solve it. I figured out I didn't need to forward the localhost, just run the python/flask app publicly. So I just had to add host='0.0.0.0' to the app.run and it was able to work.
![](../../users/profiles/106884.webp)
- 121
- 1
- 5