Hadith 1.
Sayyiduna Abu Darda narrated that he heard Allah's Messenger ﷺ say, ''When a person curses anything (man or an inanimate object), the curse rises up to the heaven but the gates of heaven are locked against it, so it comes down to earth but its gates are locked against it. So, it turns to the right and the left. If it does not find any point of entry, it comes again to that which was cursed (and effects it) if it deserves the curse. If not then it reverts on him who had uttered the curse." Abu Dawud.
COMMENTARY: People take the curse very lightly but this hadith points out how serious it is and the one who curses is himself liable to fall prey to it.
Hence, no one may be cursed unless one is confident that he deserves it, but this can only be known when the Prophet ﷺ tells us who deserves it.
Hadith 2.
Sayyiduna Ibn Abbas narrated that (one day) the wind blew away the cloak of a man, so he cursed it. Allah's Messenger said,
"Do not curse it, because it is under command. If any one curses something and it is not liable to it, then the curse rebounds to him." Tirmidhi & Abu Dawud.
COMMENTARY: the wind is not independent but it follows the command of Allah. Hence, it is very bad to curse it and it is contrary to servitude.
The same command applies at other occasions like when facing reverses of fortune or grief, etc. One must keep one's tongue in check. No complaint must be made. It is against Islamic teachings.
Hadith 3.
Sayyiduna Abu Darda narrated that he heard Allah's Messenger ﷺ say, "those who are accustomed to curse often will not be witnesses or intercessors on the day of resurrection." (Muslim)
COMMENTARY: On the day of resurrection, the ummah of Muhammad ﷺ will be presented as witnesses over the previous peoples. They will testify that the Prophet ﷺ had conveyed to those peoples the messages of Allah and had invited them to Allah's path. But, they did not listen to them. Allah says about it:
{And thus have we made you mid-most justly balanced) community so that you may be witnesses to mankind.} (2: 143) The Prophet ﷺ said that on the day of resurrection such people who are given to cursing will not be honoured as witnesses over the past ummahs, they will also be deprived of the honour of interceding (doing Shifa'at) for anyone on the day of resurrection.
This is why the Ahl us sunnah wa al jama'ah refrain from cursing anybody, even if he deserves it. However, there is no harm in cursing the disbelievers about whom it is known for certain that they died as disbelievers.