Congestion in DTN is a prominent problem due to constrained resource, intermittent link and long propagation delay. Traditional congestion control mechanisms based on end-to-end feedback and rate control fail to work in such network environments. Considering the characteristics of DTN, we propose a new contact-based congestion avoidance mechanism (C2AM). The contact history and queuing information are both exploited to obtain the average sojourn time of each incoming message. Using this metric, we try to deter incoming messages with long sojourn time and large size. Motivated by Little’s law, we introduce the average storage cost of each message. To our best knowledge, this is the first case where contact information is used to assist congestion control in DTNs. Using simulation, we evaluate the C2AM mechanism and show that it can avoid and alleviate congestion in DTN greatly and improves network performance.