OpenWrt Forum Archive

Topic: uhttpd not working in r39320?

The content of this topic has been archived on 7 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Trying the latest build off of trunk (via git), r39320, and after flashing a factory image of a local build to my WNDR3800 router, everything boots up fine except uhttpd.  As such, LuCI doesn't work.

Some debugging I did was to edit /etc/init.d/uhttpd and uncomment these lines:

        # Check if daemon is running, if not then
        # re-execute in foreground to display error.
        sleep 1 && service_check $UHTTPD_BIN || \
                $UHTTPD_BIN -f $UHTTPD_ARGS

Which gives me this error:

root@OpenWrt:/# /etc/init.d/uhttpd start
Error: No sockets bound, unable to continue

Some more poking around hints that uhttpd is looking for a /ubus dir, which I am missing in my rootfs.  However, while I appear to have included all ubus-related options in my config and I have /bin/ubus, it does not appear to be a daemon process, so  don't know if it is responsible for creating /ubus or not.

I can start uhttpd manually:

root@OpenWrt:/# uhttpd -p 80 -h /www

And LuCI will work fine, but this obviously won't survive a reboot.

It's possible I left something out of my config, however, my previous config worked fine (r38958), and that's what I based my new config off of.

Ideas?

(Last edited by Kumba on 19 Jan 2014, 03:19)

Post your /etc/config/uhttpd.

jow wrote:

Post your /etc/config/uhttpd.


Here you go:

config uhttpd 'main'
        list listen_http '0.0.0.0:80'
        list listen_https '0.0.0.0:443'
        option home '/www'
        option rfc1918_filter '1'
        option cert '/etc/uhttpd.crt'
        option key '/etc/uhttpd.key'
        option cgi_prefix '/cgi-bin'
        option script_timeout '60'
        option network_timeout '30'
        option tcp_keepalive '1'
        option ubus_prefix '/ubus'

config cert 'px5g'
        option days '730'
        option bits '1024'
        option country 'DE'
        option state 'Berlin'
        option location 'Berlin'
        option commonname 'OpenWrt'

PS, temporarily solved by adding "uhttpd -p 80 -h /www" to rc.local.  I'd open a ticket, but Trac keeps timing out (HTTP 504) on the nginx gateway everytime I attempt to login or reset my password.

People probably hate this, but "bump"...

I just flashed my WNDR3800 with trunk 39442 and uhttpd runs ok.
So, it is likely something related to either your build config or your settings.

Your uhttpd config seems to be missing some lines that are in its current default config. Maybe you should copy the current default from /rom/etc/config/uhttpd to /etc/config/uhttpd ?  Although the three missing lines do not seem that important:
        option max_requests '3'
        option max_connections '100'
        option http_keepalive '20'

In general, when using trunk builds, is pays off to rebuild the config files in /etc/config every now and then in order to get the current defaults. (And the same goes for build settings in .config)

If you want, feel free to test my build with your WNDR3800. Flash without saving settings and then rebuild them manually.
https://forum.openwrt.org/viewtopic.php?id=28392

(Last edited by hnyman on 1 Feb 2014, 22:34)

hnyman wrote:

I just flashed my WNDR3800 with trunk 39442 and uhttpd runs ok.
So, it is likely something related to either your build config or your settings.

Your uhttpd config seems to be missing some lines that are in its current default config. Maybe you should copy the current default from /rom/etc/config/uhttpd to /etc/config/uhttpd ?  Although the three missing lines do not seem that important:
        option max_requests '3'
        option max_connections '100'
        option http_keepalive '20'

Oddly enough, that seems to have done it.

I see this in the 'ps' output:

/usr/sbin/uhttpd -f -h /www -r <router-name> -x /cgi-bin -t 60 -T 30 -k 20 -A 1 -n 3 -N 100 -R -p 0.0.0.0 80 -C /etc/uhttpd.crt -K /etc/uhttpd.key -s 0.0.0.0 443

Sometimes, it's the simple fixes in life.


Now to figure out how to get IPv6 working.  I have a eorking IPv6 internal LAN, statically-assigned.  Have to work out handing out my ISP's block now...

I hate to bring this up again but I'm still having problems... I thought this was an issue related to an old /etc/config/uhttpd file but I just did an upgrade to the latest snapshot version (and wiped out the old /etc/config/uhttpd file) and tried installing uhttpd and it refuses to start. If I enable the /etc/init.d/uhttpd debugging I get the message "Error: No sockets bound, unable to continue" but clearly I do have "list listen_http        0.0.0.0:80" in my /etc/config/uhttpd file!

Any suggestions?

I pulled out another one of these routers and did a fresh install without saving the configuration files. On that router uhttpd works just fine so it's clearly something with the old configuration files somewhere. I have tried deleting the /etc/config/uhttpd and /etc/config/luci files before installing the packages while keeping the other configuration files but that doesn't seem to make a difference. Any other ideas on what old configuration files I could try deleting?

I know I could fix it by wiping the entire configuration and starting over but I have many of these routers out with this problem and would really like to find the root cause.

I have exactly the same problem....occurs after update from 12,09 to latest trunk (Powered by LuCI Trunk (svn-r10375) OpenWrt Barrier Breaker r41391)

/usr/sbin/uhttpd -f -h /www -p 80 works fine, but it's workaround only.

root@OpenWrt:/etc/config# uci show uhttpd
uhttpd.main=uhttpd
uhttpd.main.listen_http=0.0.0.0:80
uhttpd.main.listen_https=0.0.0.0:443
uhttpd.main.home=/www
uhttpd.main.rfc1918_filter=1
uhttpd.main.cert=/etc/uhttpd.crt
uhttpd.main.key=/etc/uhttpd.key
uhttpd.main.cgi_prefix=/cgi-bin
uhttpd.main.script_timeout=60
uhttpd.main.network_timeout=30
uhttpd.main.tcp_keepalive=1
uhttpd.px5g=cert
uhttpd.px5g.days=730
uhttpd.px5g.bits=1024
uhttpd.px5g.country=DE
uhttpd.px5g.state=Berlin
uhttpd.px5g.location=Berlin
uhttpd.px5g.commonname=OpenWrt
root@OpenWrt:/etc/config# uci show luci
luci.main=core
luci.main.lang=auto
luci.main.resourcebase=/luci-static/resources
luci.main.mediaurlbase=/luci-static/bootstrap
luci.flash_keep=extern
luci.flash_keep.uci=/etc/config/
luci.flash_keep.dropbear=/etc/dropbear/
luci.flash_keep.openvpn=/etc/openvpn/
luci.flash_keep.passwd=/etc/passwd
luci.flash_keep.opkg=/etc/opkg.conf
luci.flash_keep.firewall=/etc/firewall.user
luci.flash_keep.uploads=/lib/uci/upload/
luci.languages=internal
luci.languages.en=English
luci.sauth=internal
luci.sauth.sessionpath=/tmp/luci-sessions
luci.sauth.sessiontime=3600
luci.ccache=internal
luci.ccache.enable=1
luci.themes=internal
luci.themes.Bootstrap=/luci-static/bootstrap
luci.themes.OpenWrt=/luci-static/openwrt.org

Any idea please ?

Does the config contain "option listen_http" or "list listen_http" ?

Thank you, yes, it does - this is the content of uhttpd :

config uhttpd 'main'
        list listen_http '0.0.0.0:80'
        list listen_https '0.0.0.0:443'
        option home '/www'
        option rfc1918_filter '1'
        option cert '/etc/uhttpd.crt'
        option key '/etc/uhttpd.key'
        option cgi_prefix '/cgi-bin'
        option script_timeout '60'
        option network_timeout '30'
        option tcp_keepalive '1'
        option ubus_prefix '/ubus'

config cert 'px5g'
        option days '730'
        option bits '1024'
        option country 'DE'
        option state 'Berlin'
        option location 'Berlin'
        option commonname 'OpenWrt'

And this is what I get when launching it manually :

root@OpenWrt:/etc/config# /usr/sbin/uhttpd -c /etc/config/uhttpd
Error: No sockets bound, unable to continue

You can't use -c /etc/config/uhttpd. That config file is in Openwrt UCI format, it needs to be read by the init script and translated into arguments uhttpd can understand.

OK, understood, anyway, I was just trying by this to debug the problem, as

/etc/init.d/uhttpd restart

...gives no output and in logread I see only :

Thu Jul  3 17:32:23 2014 user.emerg syslog: Instance uhttpd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash

Best thing to try debug is to do what the OP did:

Kumba wrote:

Some debugging I did was to edit /etc/init.d/uhttpd and uncomment these lines:

        # Check if daemon is running, if not then
        # re-execute in foreground to display error.
        sleep 1 && service_check $UHTTPD_BIN || \
                $UHTTPD_BIN -f $UHTTPD_ARGS

Which gives me this error:

root@OpenWrt:/# /etc/init.d/uhttpd start
Error: No sockets bound, unable to continue

Personally, I would also add:

echo $UHTTPD_BIN -f $UHTTPD_ARGS

just underneath that bit.

Again, thank you, really...  the result :

root@OpenWrt:/etc/init.d# ./uhttpd restart
Error: No sockets bound, unable to continue
/usr/sbin/uhttpd -f

...it looks like the config file is not parsed correctly at all.... ?

Could be, or it could be procd (which I don't have a clue about) doesn't use the same variables anymore.

No, its the debugging code which is outdated. There is no $UHTTPD_ARGS variable anymore.
Also "Instance uhttpd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash" hints at a segmentation fault.

Common causes:
uhttpd was installed later from snapshot repos on an older trunk snapshot -> abi mismatch, segfault
uhttpd-mod-tls was installed from snapshots while main uhttpd is older -> abi mismatch, segfault

So I'm screwed ... or need to perform full reinstall or I will  try reinstall and then recover config, let's see what will happen.
Thank you @qasdfdsaq anyway, much appreciated, really.

@jow, I installed latest trunk, downloaded from trunk repository and then downloaded and installed luci. So what you described as cause, should be not the case, or ? ... also why /usr/sbin/uhttpd -h /www -p 80 work normally. I'm just asking, not an expert here at all, so please don't take me wrong.

(Last edited by sharkys on 3 Jul 2014, 17:29)

...never mind, reflashed, and recreated all manually.

Thanks all for help, enjoy rest of the week ;-)

Dammit, I was just in the middle of writing some epic debug hack... >_>

So I just wanted to note that I ran into this same problem again after updating to r41663, and decided to try hnyman's suggestion:

hnyman wrote:

Maybe you should copy the current default from /rom/etc/config/uhttpd to /etc/config/uhttpd ?

And that worked.  However, I had a small error in my build config (forgot to include the ipv6 extra modules), so I had to rebuild and reflash.  I saved the config files, but it looks like the router overwrote or restored the old config, and uhttpd was refusing to start again.  I had to copy the current default uhttpd config from /rom again to get it to work.

Does anyone know if something is rewriting the uhttpd config at random?  Or does the default build image include a copy that's causing this problem?

My problem was when upgrading to r41870 I forgot to install uhttpd-mod-tls and by uncommenting the listen_https in the config uhttpd started up once again.

The discussion might have continued from here.