'Why does hardhat-ganache try to start service when running scripts?

I am coming from the truffle framework background where the deployment of scripts was straightforward, add the scripts in the migrate directory.

I want to test the deployment and learn about how transactions are created in the Ethereum chain. But seems like hardhat-ganache is trying to start the already running service. Is there any possibility to fix it?

$ DEBUG=*ganache* hardhat run scripts/deploy.ts --network ganache
hardhat:plugin:ganache Starting Ganache +0ms
  ganache Optional dependencies installed; exporting ganache-core with native optional dependencies. +0ms
  hardhat:plugin:ganache-service Initializing server +0ms
  hardhat:plugin:ganache-service Starting server +17ms
  hardhat:plugin:ganache-service An error occurred in GanacheService
  hardhat:plugin:ganache-service  Error: listen EADDRINUSE: address already in use 127.0.0.1:7545
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at GetAddrInfoReqWrap.doListen (net.js:1516:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:8) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '127.0.0.1',
  port: 7545
} +6ms
Error in plugin @nomiclabs/hardhat-ganache: An error occurred in GanacheService: listen EADDRINUSE: address already in use 127.0.0.1:7545

Here I have provided the ganache service url and from account

networks: {
    ganache: {
      url: process.env.GANACHE_URL || 'http://localhost:7545',
      from: process.env.FROM_ACCOUNT
    },


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source