Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 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.

share|improve this answer
    
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 3 '13 at 16:17

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.

share|improve this answer
    
Sorry, I forgot to mention, this doesn't work either... –  Todd Davies Jan 3 '13 at 16:12

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.