A family in Sri Lanka got the shock of their lives when they found an uninvited guest -- an 8-foot crocodile -- outside their door Sunday.

The residents of the house immediately called the wildlife conservation officers, who rushed to the home in the city of Anuradhapura to remove the reptile, News Wire reported.

Video of the rescue, which was uploaded to YouTube, showed the crocodile had no interest in leaving the front porch as it gave the officers a hard time before it was eventually removed.

The 5-minute video that has gone viral on social media showed the reptile spinning around and using its full strength to avoid being captured.

After several failed attempts, the officers finally managed to catch the reptile. They then carried the crocodile to the truck, and measured its length before driving to a nearby national park where it was released.

Nearby residents, who witnessed the rescue, told local media they believe the crocodile entered the area in search of food and water as the nearby water bodies were drying up.

After the video went viral, netizens stormed the comments section. Many echoed the villagers, saying the crocodile entered the residential area in search of water. Several social media users also praised the officers for removing the crocodile without harming it.

Sri Lanka is home to two species of crocodiles - the marsh crocodile and the saltwater crocodile. The marsh crocodiles are found in freshwater habitats like rivers and lakes, while the saltwater crocodiles are found mostly in saltwater habitats and brackish wetlands. The marsh crocodiles are smaller in size and can grow up to 5 feet in length, while the saltwater crocodiles can grow up to 17 feet.

In 2016, the largest crocodile in Sri Lanka, measuring 17 feet and weighing close to 2,000 pounds, was found stuck in a canal in the southern city of Matara. Reports had stated the reptile was searching for food when it got trapped in the canal off a river after the water levels in the river rose following heavy rain. The crocodile was rescued, put in a truck and released into the river.

Saltwater crocodiles are known to inhabit the area around Australia's Lake Placid, but attacks are relatively rare
Representational image AFP / SAEED KHAN