wifi-connect icon indicating copy to clipboard operation
wifi-connect copied to clipboard

Error: Cannot start HTTP server on '192.168.42.1:80': address in use

Open sscirrus opened this issue 4 years ago • 11 comments

I am running WiFi-Connect 4.3.1 on a Beaglebone Black Wireless (arm7l) using the latest Buster image for Beaglebone (kernel 4.19.94-ti-r42).

I installed Wifi-Connect and am trying to start it up.

Error:

root@beaglebone:/home/debian# wifi-connect
WiFi device: wlan0
Access points: ["GHHA 2.4", "DTH018.F2262H-2.4G", "GHHA-EXT"]
Starting access point...
Access point 'WiFi Connect' created
Starting HTTP server on 192.168.42.1:80
Error: Cannot start HTTP server on '192.168.42.1:80': address in use
root@beaglebone:/home/debian# 
dnsmasq: failed to bind DHCP server socket: Address already in use

Note that despite this error, my laptop is able to find the WiFi network that's been created - it just cannot connect successfully.

What I've tried:

  1. connmanctl disable wifi AND systemctl disable dnsmasq -> changes error to 'Creating the captive portal failed'.
  2. connmanctl disable wifi -> 'Creating the captive portal failed'.
  3. systemctl disable dnsmasq -> original error.
  4. Change port from 80 to 81 -> original error.
  5. Change IP to various numbers inside and outside the 192.168.42.* range -> original error.
  6. Disable device's tether -> tether already disabled.
  7. Disable Cloud9 IDE and bonescript -> original error.
  8. Scan local IP addresses using nmap: nmap -sP 192.168.42.* -> 256 IP addresses (0 hosts up) scanned...
  9. Change port: wifi-connect -o 8001 -> Starting HTTP server! BUT dnsmasq: failed to bind DHCP server socket: Address already in use.

I cannot seem to find the right way to get the thing to start! I'd greatly appreciate any help.

What's running:

netstat -tupln
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1022/nginx: master  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1022/nginx: master  
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1888/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      934/sshd            
tcp6       0      0 :::8080                 :::*                    LISTEN      1022/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      1022/nginx: master  
tcp6       0      0 :::53                   :::*                    LISTEN      1888/dnsmasq        
tcp6       0      0 :::22                   :::*                    LISTEN      934/sshd            
tcp6       0      0 :::3000                 :::*                    LISTEN      1/init              
tcp6       0      0 :::1880                 :::*                    LISTEN      1/init              
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           810/avahi-daemon: r 
udp        0      0 0.0.0.0:36616           0.0.0.0:*                           810/avahi-daemon: r 
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1888/dnsmasq        
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1888/dnsmasq        
udp6       0      0 :::34535                :::*                                810/avahi-daemon: r 
udp6       0      0 :::5353                 :::*                                810/avahi-daemon: r 
udp6       0      0 :::53                   :::*                                1888/dnsmasq

sscirrus avatar Jun 26 '20 10:06 sscirrus

Can you please try running it with sudo?

majorz avatar Jun 26 '20 18:06 majorz

@majorz I ran it again with sudo, but I get the same result as with #9, i.e. that the HTTP server is started, but dnsmasq 'failed to bind DHCP server socket: Address already in use'.

I've added the results of netstat -tupln above in case it's helpful.

sscirrus avatar Jun 26 '20 19:06 sscirrus

Let's see whether stopping the other dnsmasq instance that shows in the netstat output will solve this: sudo systemctl stop dnsmasq. And then double check that it is no longer running with netstat again.

BTW, you can use multi-line formatting with triple quotes "```":

Line 1
Line 2

majorz avatar Jun 26 '20 19:06 majorz

Ah, I see you figured the block quoting.

majorz avatar Jun 26 '20 19:06 majorz

@majorz I just ran:

root@beaglebone:/home/debian# sudo systemctl stop dnsmasq
root@beaglebone:/home/debian# sudo wifi-connect
Deleting already created by WiFi Connect access point connection profile: "WiFi Connect"
WiFi device: wlan0
Access points: [...]
Starting access point...
Access point 'WiFi Connect' created
Starting HTTP server on 192.168.42.1:80
Error: Cannot start HTTP server on '192.168.42.1:80': address in use

It seems that this time it can't start the HTTP server. Before, it was starting the HTTP server but failing at the next step.

sscirrus avatar Jun 26 '20 19:06 sscirrus

@majorz

I then tried running the same thing but changing the port:

root@beaglebone:/home/debian# sudo wifi-connect -o 8001
Deleting already created by WiFi Connect access point connection profile: "WiFi Connect"
WiFi device: wlan0
Access points: [...]
Starting access point...
Access point 'WiFi Connect' created
Starting HTTP server on 192.168.42.1:8001

dnsmasq: failed to create listening socket for 192.168.42.1: Address already in use

OK something new happened: my PC now detects the network 'Wifi Connect' and I was able to connect to it for the first time and bring up the network selection page. This hasn't happened before - last night, it was trying and trying but wouldn't connect.

I'm still getting this 'failed to create listening socket' and I don't know what the implications of that are.

sscirrus avatar Jun 26 '20 19:06 sscirrus

same issue here. Any solutions yet?

kennyparsons avatar Jul 07 '20 23:07 kennyparsons

same issue here. Any solutions yet?

@kennyparsons afraid not... the system seems to work but it isn't stable and I'm still getting error messages.

sscirrus avatar Jul 09 '20 06:07 sscirrus

I found a solution at #232 :

sudo apt install dnsmasq
sudo systemctl stop dnsmasq
sudo ./wifi-connect

it's work on Armbian_21.08.1_Orangepizero_buster_current_5.10.60.img.xz.

hugo2017 avatar Nov 16 '21 14:11 hugo2017

Access point 'WiFi Connect' created Starting HTTP server on 192.168.42.1:8001

dnsmasq: failed to create listening socket for 192.168.42.1: Address already in use

For me it started working after a reboot.

btzs avatar Jun 08 '22 00:06 btzs

I found a solution at #232 :

sudo apt install dnsmasq
sudo systemctl stop dnsmasq
sudo ./wifi-connect

it's work on Armbian_21.08.1_Orangepizero_buster_current_5.10.60.img.xz.

For anyone encountering this error in 2023, this solution worked for me. You have to install the dnsmasq package, yet have it disabled.

You can disable it from starting on boot with "systemctl disable dnsmasq"

SBJakobsen avatar Jun 02 '23 10:06 SBJakobsen