Local residents said they heard gunfire and several explosions but police said there were no civilian casualties.
The attack on the large compound, known as the Green Village, is the second this week targeting foreign workers.
On Monday, two Afghan security guards were killed in a Taliban attack on another Western compound.
"Four suicide bombers have been killed, there was no harm to civilians," Deputy Interior Minister Mohammad Ayub Salangi told reporters.
A Taliban spokesman said the group was behind the attack.
The attackers tried to break into the Green Village by detonating a car packed with explosives at the entrance to the compound, which houses foreign contractors and security staff.
"Since the Green Village had been targeted several times in the past, the place was heavily guarded and the attackers failed to reach their intended target," Interior Ministry spokesman Sediq Sediqqi said.
The compound was last targeted in October 2013 when a suicide bomber killed two passers-by. Another attack in 2012 killed seven guards and civilians.
Attacks on foreign workers, government officials and security forces have intensified in recent weeks as Western troops end their operations.
Last week, a suicide bomber targeted a prominent female Afghan politician, killing three civilians and wounding others in an attack on a Kabul convoy.
A week earlier, another suicide attacker entered the offices of Kabul's police chief and killed a senior officer.

Celtic had offered United £250,000 to take winger Mackay-Steven, 24, now rather than wait until the summer, a move that had already been agreed.
And the Glasgow club agreed a deal for both players of £2m plus add-ons.
"I'm delighted to be here and to have signed on at such a massive club," Armstrong, 22, told BBC Scotland.
Mackay-Steven added: "I'm absolutely delighted to be here and to get everything done and dusted today. It's been a crazy few hours but I'm over the moon."
Celtic's increased £1.6m offer for Armstrong had been rejected on Sunday before further talks took place on Monday.
The Scottish champions had a £1.5m offer for the Scotland Under-21 international rejected last week and Burnley also had a bid turned down.
The £250,000 offer for Scotland cap Mackay-Steven was £100,000 more than they had previously offered.
Armstrong, who has signed until 2018, and Mackay-Steven, whose deal runs until 2019, will be ineligible for Celtic's Scottish Cup meeting with Dundee on Saturday and next month's League Cup final meeting with their former club.
United defeated Aberdeen 2-1 at Hampden Park in Saturday's semi-final, with Celtic recording a 2-0 victory over Rangers the following day.
And United will ask for at least 17,500 tickets for the 15 March showpiece.
The Tannadice board will also request that tickets outside of the corporate and main stand be priced at a maximum of £25 for adults and £10 for concessions.
One director told BBC Scotland: "We want to ensure as big a crowd as possible for the game, which we are sure the sponsors would want too.
"The game is being played in winter and, to make sure the game attracts as big a crowd as a possible, we will ask for tickets to be priced at a reasonable level.
"That is very important for the fans of both clubs when money is tight."
It is believed that United will also ask for the Toryglen end of the stadium to be reserved for their fans at a planning meeting on Tuesday with the Scottish Professional Football League about the final.
However, BBC Scotland has learned that the SPFL will stick with tradition and allocate that end of the ground to Celtic fans.
Officials in Kabul say police killed four Taliban suicide bombers during an attack on a compound housing foreign workers in the Afghan capital.
[NEXT_CONCEPT]
Midfielder Stuart Armstrong and winger Gary Mackay-Steven have joined Celtic from Dundee United after the clubs agreed deals on transfer deadline day.