This is an interesting question, with a complicated answer. At first the Spanish didn't block Dutch trade, since the Netherlands were part of the Spanish empire. That some parts were temporarily in revolt doesn't mean you have to take economic measures against all of it.
In 1585 the Dutch rebels and the English crown signed a treaty in which the English agreed to send soldiers and money to assist the Dutch in the war against Spain. The Spanish king Philip II reacted by placing an embargo on Dutch and English ships and cargoes. Neither country was allowed to trade in ports on the Iberian peninsula. This measure was not 100% effective, but it did make trade a lot more difficult and dangerous.
In 1590 Philip II lifted the embargo against Dutch shipping (for reasons which are unknown to me), but the embargo on English shipping remained intact. This gave the Dutch a huge advantage in trade in northern Europe. They had access to spices and other exotic products via the Spanish and Portuguese ports, whereas the English didn't. Dutch trade flourished and Amsterdam became the hub in northern Europe for trade in spices.
Spanish ministers realised what happened, so when Philip III took the throne in 1598 the embargo on Dutch shipping and cargoes was reimposed. The Dutch went looking for their own routes to the Indies to stay involved in the lucrative spice trade - this led to the VOC (Dutch East India Company). The Dutch also reacted by sending fleets of warships to harass shipping off the Spanish and Portuguese coast - in 1607 they even sailed into the Bay of Gibraltar, destroying 10 Spanish galleons and a dozen other ships.
From 1604 the Dutch found themselves in the reverse situation of the 1590s. The English signed a peace treaty with the Spanish. Not only did this mean that the English could now trade in the Spanish and Portuguese ports while the Dutch could not, the treaty also included a clause which forbade the English to carry goods for Dutch merchants when trading with Spain or Portugal.
The English peace with Spain was threat to Dutch commerce. The Dutch had experienced how much a difference access to Iberian ports could make. Everything was fine so long as the Dutch Republic and England were both banned from those ports, but now that the English had access while the Dutch had not, Dutch trade in northern Europe would suffer. This realisation led to the start of peace talks with Spain.
Though no permanent peace terms could be agreed upon, the Spanish and the Dutch did agree to a truce lasting twelve years (aptly named the Twelve Years' Truce). This made it possible for for Dutch ships to once again trade in Spanish and Portuguese ports. It had the added benefit of making trade with the Mediterranean and the Levant less risky, as sailing past the Iberian peninsula was now virtually risk-free.
Trade with Spain lasted until the resumption of hostilities in Europe in 1621. From then on the situation was less complex. Spain and the Dutch Republic were at war, and no direct trade was allowed until the end of the war.