So lan_ip sometimes can be an input from datastore['RHOST'].  That can be a domain name, but your line here is expecting an IP.  Perhaps you need to do a check beforehand.