This phase I trial studies the side effects and best dose of erlotinib hydrochloride in treating non-small cell lung cancer that has spread to other parts of the body or cannot be removed by surgery in patients with human immunodeficiency virus (HIV) infection. Erlotinib hydrochloride may stop the growth of tumor cells by blocking some of the enzymes needed for cell growth. Erlotinib hydrochloride is a standard drug used for treating lung cancer, however, it is not yet known whether it is safe to give erlotinib hydrochloride to patients who also have HIV infection or not.