2

I usually write code, not administer servers, so bear with me here!

I'm running a python script to act as a webserver and I also have Apache installed on the same machine.

When I run the python script, I get the success message:

Running on http://127.0.0.1:5000/

However, when browse to the IP address of my server on my local network (192.168.0.2) I get the Apache page. When I browse to 192.168.0.2:5000 I get 'Oops! Google Chrome could not connect to 192.168.0.2:5000'.

How do I have the python server work on the local network instead of Apache?

Todd Davies
  • 121
  • 1
  • 4

3 Answers3

3

It's running (listening) on 127.0.0.1 and not on 192.168.0.2.

Fix the script to listen on the desired address, and it should work on http://192.168.0.2:5000/.

If you want it to run on port 80, change the script to listen on that port, turn off Apache, and restart the script.

mulaz
  • 10,472
  • 1
  • 30
  • 37
  • Thanks, this worked. I am using Flask which I'm not familiar with but I used `app.run(host='192.168.0.2')` to make it listen on the local network, thanks! – Todd Davies Jan 03 '13 at 16:17
1

Connect using http://192.168.0.2:5000.

You need to include the port in the URL, if you don't, it defaults to 80.

MDMarra
  • 100,183
  • 32
  • 195
  • 326
0

Your python script is running it's own web server that is bound to your local machine on port 5000. To access your python application, you need to access it at

http://192.168.0.2:5000

If you want to replace apache altogether, you will basically need to stop the apache web server and bind your python script on port 80. Depending on your operating system, you may or may not need elevated privileges to bind on port 80.

If you are still unable to access the python app from 192.168.0.2:5000, you need to specifically bind the application to

http://0.0.0.0:5000 

so it knows to listen on all interfaces, not just the loopback interface.

Ethan Hayon
  • 235
  • 1
  • 6