3

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 4

5

As the forwarding part has not been addressed by any of the previous answers yet: you can easily forward local ports using SSH:

    ssh [email protected] -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".

2
  • 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. Jan 13, 2012 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 <specific name / version> to my public interface instead of 127.0.0.1?"
    – the-wabbit
    Jan 13, 2012 at 17:37
1

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.

0

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .