lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.94k stars 548 forks source link

Could not bind socket. error #81

Closed wenxueliu closed 9 years ago

wenxueliu commented 9 years ago

$ uname -a Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux

$ sudo ./lwan 7122 lwan-job.c:76 lwan_job_thread_init() Initializing low priority job thread. 7122 lwan-response.c:75 lwan_response_init() Initializing default response. 7122 lwan-tables.c:40 lwan_tables_init() Uncompressing MIME type table. 7122 lwan.c:52 lwan_module_init() Initializing module registry. 7122 lwan.c:67 lwan_module_register() Registering module "serve_files". 7122 lwan.c:67 lwan_module_register() Registering module "redirect". 7122 lwan.c:67 lwan_module_register() Registering module "lua". 7122 lwan.c:328 setup_from_config() Loading configuration file: lwan.conf. 7122 lwan.c:442 lwan_init() Could not read config file, using defaults. 7122 lwan.c:445 lwan_init() Initializing lwan web server. 7122 lwan.c:456 lwan_init() Using 2 threads, maximum 2048 sockets per thread. 7122 lwan-thread.c:391 lwan_thread_init() Initializing threads. 7122 lwan-socket.c:226 lwan_socket_init() Initializing sockets. 7122 lwan-socket.c:189 bind_and_listen_addrinfos() Could not bind socket. 7125 lwan-thread.c:288 thread_io_loop() Starting IO loop on thread #2. 7124 lwan-thread.c:288 thread_io_loop() Starting IO loop on thread #1.

lpereira commented 9 years ago

What are your network interfaces? Since Lwan couldn't find the configuration file, it'll try to bind to localhost:8080, and you might not have an entry for localhost in your /etc/hosts file (which is odd but possible). Try copying the lwan.conf file to the directory it is running on, and changing the listener line to read listener *:8080 { so that it tries binding to all interfaces, or listener 127.0.0.1:8080 { if you'd like it to listen only on that particular interface. Please ensure that this interface is up and running (check with either ifconfig or ip).

I'm not sure also if Lwan works under ARM correctly even if it manages to bind to a network interface. Some of the used tricks might only work on x86.

wenxueliu commented 9 years ago

I have slove the problem by netstat -lntp