HTTP service can't be started on boot
I didn't have time to dig into the details but monit is not able to start http service on boot.
Probably somehow related to #192.
NOTE: the address is specified by ip, not by name(localhost).
Error messages:
Starting Monit 5.20.0 daemon with http interface at [127.0.0.1]:2812
HTTP server -- Cannot translate IPv4 socket [127.0.0.1]:2812 -- Name or service not known
HTTP server -- Invalid socket family 3
This is unrelated to the status of lo. If lo is down monit can't bind for another reason:
Starting Monit 5.20.0 daemon with http interface at [127.0.0.1]:2812
HTTP server -- Cannot bind: Cannot assign requested address
HTTP server -- Invalid socket family 3
The status of network is ok before monit is started. It's true the eth0
doesn't have ip address but it shouldn't be an issue.
>ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope link
valid_lft forever preferred_lft forever
>ping -c 1 localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.152 ms
--- localhost ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.152/0.152/0.152 ms
The /etc/resolv.conf
is empty.
All in all the service is configured by the ip address, why monit is trying to resolve it?
The configuration section:
set httpd port 2812 and
use address 127.0.0.1
allow localhost
allow admin:monit
Any suggestion on how to gracefully restart monit http service?
Comments (9)
-
reporter -
repo owner - changed status to duplicate
Duplicate of
#537. -
reporter It's not duplicate as:
- lo interface available
- using monit v5.20
- no need to resolve host if given IP
monit -V This is Monit version 5.20.0 Built with ssl, without ipv6, with compression, without pam and with large files Copyright (C) 2001-2016 Tildeslash Ltd. All Rights Reserved.
-
reporter - changed status to open
-
repo owner Does this work?
nc -4 -l 127.0.0.1 2812
. Also note that the bug fix mentioned in the duplicate issue is not part of 5.20.0. -
repo owner - changed status to closed
No reply from user, assuming IP 4/6 configuration issue on user's local machine.
-
reporter - changed status to open
Netcat can bind successfully. I added following commands just before launching monit in the init script:
(rm /tmp/test; \ nc -l -p 2812 127.0.0.1 > /tmp/test& \ netstat -ntpl; echo test | nc 127.0.0.1 2812; \ cat /tmp/test) | logger -t monit
Netcat is from busybox but it doesn't change the meaning.
Following output was captured:
user.notice monit: Active Internet connections (only servers) user.notice monit: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name user.notice monit: tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN 413/nginx user.notice monit: tcp 0 0 127.0.0.1:7778 0.0.0.0:* LISTEN 413/nginx user.notice monit: tcp 0 0 127.0.0.1:9001 0.0.0.0:* LISTEN 444/uwsgi user.notice monit: tcp 0 0 127.0.0.1:1649 0.0.0.0:* LISTEN 392/lsh user.notice monit: tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 334/dropbear user.notice monit: tcp 0 0 127.0.0.1:2812 0.0.0.0:* LISTEN 454/nc user.notice monit: tcp 0 0 127.0.0.1:1212 0.0.0.0:* LISTEN 431/python3 user.notice monit: tcp 0 0 :::22 :::* LISTEN 334/dropbear user.notice monit: test user.info monit[459]: Starting Monit 5.20.0 daemon with http interface at [127.0.0.1]:2812 user.info monit[461]: 'Lima' Monit 5.20.0 started user.err monit[461]: HTTP server -- Cannot translate IPv4 socket [127.0.0.1]:2812 -- Name or service not known user.err monit[461]: HTTP server -- Invalid socket family 3
-
Thanks Dmytro Milinevskyi, unixsocket solved this issue for me for monit 5.19!!!
-
repo owner - changed status to resolved
As mentioned, the fix is not part of Monit 5.20.0 ... it is related to AI_ADDRCONFIG resolver option, which was fixed in Monit 5.21.0.
- Log in to comment
The solution I've found is to use unix socket: