1

I have problem running python bottle server on linux. I installed the python and bottle on my linux box. I ran a simple testPort.py program.

It started successfully:

$ sudo python ~/bottle-0.11.6/bottle-0.11.6/test/testPort.py 
Bottle v0.11.6 server starting up (using WSGIRefServer())...
Listening on http://onpoint.stanford.edu:1008/
Hit Ctrl-C to quit.

But when I used google chrome to access it: http://onpoint.stanford.edu:1008

I got the message the webpage is not available. Can anyone help me on this?

I checked the server, there is no activities.

Here is my linux version:

webmc@onpoint:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 13.04
Release:        13.04
Codename:       raring

I used the following command to check if the port is open. It seems it did open:

webmc@onpoint:~$ sudo netstat --tcp --udp --listening --program
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:6010          *:*                     LISTEN      59035/10        
tcp        0      0 localhost:5914          *:*                     LISTEN      46633/Xvnc      
tcp        0      0 localhost:6011          *:*                     LISTEN      53146/1         
tcp        0      0 *:46843                 *:*                     LISTEN      46694/smpd      
tcp        0      0 localhost:5915          *:*                     LISTEN      47007/Xvnc      
tcp        0      0 localhost:6012          *:*                     LISTEN      45889/7         
tcp        0      0 localhost:5916          *:*                     LISTEN      52254/Xvnc      
tcp        0      0 *:36349                 *:*                     LISTEN      54825/mpiexec   
tcp        0      0 localhost:6013          *:*                     LISTEN      46157/9         
tcp        0      0 *:3389                  *:*                     LISTEN      40078/xrdp      
tcp        0      0 localhost:5917          *:*                     LISTEN      61999/Xvnc      
tcp        0      0 *:microsoft-ds          *:*                     LISTEN      1401/smbd       
tcp        0      0 localhost:5918          *:*                     LISTEN      56300/Xvnc      
tcp        0      0 localhost:5919          *:*                     LISTEN      36383/Xvnc      
tcp        0      0 localhost:5920          *:*                     LISTEN      41164/Xvnc      
tcp        0      0 *:39396                 *:*                     LISTEN      54835/MATLAB    
tcp        0      0 *:43333                 *:*                     LISTEN      54830/MATLAB    
tcp        0      0 *:51112                 *:*                     LISTEN      54837/MATLAB    
tcp        0      0 localhost:mysql         *:*                     LISTEN      1974/mysqld     
tcp        0      0 *:netbios-ssn           *:*                     LISTEN      1401/smbd       
tcp        0      0 *:60591                 *:*                     LISTEN      54828/MATLAB    
tcp        0      0 onpoint.Stanford.E:1008 *:*                     LISTEN      7064/python 

Here is my testport.py:

from bottle import Bottle, run, template

app = Bottle()

@app.route('/hello')
def hello():
    return "Hello World!"

run(app, host='onpoint.stanford.edu', port=1008)
5
  • Did you also navigate to onpoint.stanford.edu:1008/hello ? Commented Jan 15, 2014 at 20:19
  • Yes, I did do onpoint.stanford.edu:1008/hello and it gave me "the web page is not available" error. Any hint? Commented Jan 16, 2014 at 5:50
  • You might do debug=True to see if there are any errors. Commented Jan 16, 2014 at 5:57
  • Hi, thank you for the comments. I put "debug=True" in run function. But I did not get any additional output after starting the server.Here is the only output after starting the server:webmc@onpoint:~/bottle-0.11.6/bottle-0.11.6/test$ sudo python testPort.py [sudo] password for webmc: Bottle v0.11.6 server starting up (using WSGIRefServer())... Listening on onpoint.stanford.edu:1008 Hit Ctrl-C to quit. Commented Jan 16, 2014 at 19:41
  • I tried "telnet localhost 80" on it and it worked(an apache web server is running on port 80 and it worked), but I tried "telnet localhost 1008"(bottle server), it gave me "unable to connect to remote host:connection refused". I tried "telnet onpoint.stanford.edu 1008" and the command works fine. So I assume the port of 1008 is opened correctly. Commented Jan 16, 2014 at 19:50

2 Answers 2

1

Might be a hostname problem. Try:

run(app, host='127.0.0.1', port=1008)

Then hit:

http://127.0.0.1:1008/hello

N.B., If you're hitting this server from another machine, you may also have to open a hole in your firewall. (If you want help with that you should probably open a new question, since it's truly a separate issue.)

4
  • i also faced problem like that try with localhost Commented Jan 17, 2014 at 6:11
  • Hi, I think I have to write the machine name since I need to access it from other machine by http. I think it may be firewall issue. The port seems open. I tried iptables command, but not working. Commented Jan 18, 2014 at 5:50
  • Want to clarify, it seems it works on localhost, but not from remote. Commented Jan 18, 2014 at 6:02
  • Ah, I see. So your bottle problem is resolved, but it seems you now have a (separate) machine access problem to solve. You may want to check your firewall settings, among other things. Commented Jan 18, 2014 at 6:50
1

I had the same problem on an Amazon EC2 instance, and changing from localhost to 127.0.0.1 did not work for me.

To make it work, I had to use to the real IP address of my machine, as it appears on the ifconfig command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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