More than 40 people have been caught with illicit drugs at a music festival in NSW this weekend.

The individuals were found with drugs, including cannabis, MDMA, cocaine and LSD at the ‘Festival of the Sun’ in Port Macquarie.

Officers from Mid North Coast Police District conducted an operation to detect drugs at the event between December 13 to 16.

Around 3000 people attended the music festival.

One man, aged 27, was allegedly found with 55 MDMA capsules. He was charged with supply prohibited drug and possess prohibited drug.

He was conditionally bailed to appear at Port Macquarie Local Court on January 9 next year.

Other alleged offenders were given court attendance notices, infringement notices, cannabis cautions and warnings.

On-site medical services treated about 40 persons at the event for various issues.

The drug offences comes a week after a 19-year-old man died and three others were left critically ill following a suspected drug overdose at a Sydney dance party.

The teenager died in Concord Hospital early on Sunday while two women, aged 19 and 25, and a man were in critical but stable conditions at Westmead Hospital after attending the Knockout Games of Destiny dance party at Sydney Olympic Park on Saturday night.