After years of turning a blind eye to password sharing, Netflix Inc. has had enough.

The streaming giant is making moves to charge users who share their accounts with people outside of their households.

Just a few weeks after Netflix raised the price of its monthly subscriptions in the U.S., the company has said it is testing a new feature that will charge customers an extra fee for the ability to share accounts.

Netflix said the new option will be tested over the next few weeks in Chile, Costa Rica and Peru before it introduces changes in other countries.

“While these [household plans] have been hugely popular, they have also created some confusion about when and how Netflix can be shared,” Chengyi Long, Netflix’s director of product innovation, said Wednesday. “As a result, accounts are being shared between households—impacting our ability to invest in great new TV and films for our members.”

Existing subscribers will be able to add sub accounts for up to two people they don’t live with at an additional cost, she added. In Costa Rica, the feature will cost $2.99 a month, with users in Chile and Peru being charged the local equivalent.

Netflix stands to lose more people than it would gain from doing this, and risks making users mad, said Michael Pachter, a research analyst at Wedbush Securities, who upgraded his rating on the company to neutral last week. 

“I believe that a crackdown on password sharing is going to increase churn,” he said, referring to the rate at which customers leave the service. He said the company should stop dumping content all at once, and instead space out the release of its programming, which would help keep subscribers from binge-watching and then leaving the service.

In January, the company raised the price for its monthly plans, the first such increase from the streaming platform since 2020. The monthly cost for its basic plan for U.S. customers rose $1 to $9.99, while its standard plan increased to $15.49 from $13.99 and the premium plan to $19.99 from $17.99.

This isn’t the first time Netflix has experimented with tightening account security. In March 2021, the company started prompting some of its users to verify their identity through a text message.

Netflix’s rivals, including AT&T’s HBO Max and Walt Disney Co. ’s Disney+, often email their customers when they notice multiple logins from various locations, according to people familiar with the companies’ policies. The emails usually say that the service wants to ensure the user’s account wasn’t hacked, the people said. But they also serve as a gentle reminder to customers that companies know when more than one person is using the account, industry experts said.

The move comes amid increased competition among streaming platforms and rising programming costs. Netflix is spending more on content to attract and keep subscribers as viewers have more content than ever to choose from thanks to a crowded field.

In January, the company said it expected to add a much smaller number of subscribers this quarter than it did a year ago as it adjusts to growing competition and lasting disruptions from the pandemic, sending the video streamer’s shares down sharply. The company forecast an increase of 2.5 million subscribers in the current quarter, compared with four million a year earlier. It also slightly missed its subscriber estimate for the fourth quarter of 2021, adding 8.3 million subscribers instead of the projected 8.5 million.

Allison Prang contributed to this article.

Write to Gareth Vipers at gareth.vipers@wsj.com