Truffle – How to Change Truffle Develop Port

truffle

When I run truffle develop it starts a testnet listening at localhost:9545. Is there a way to change the port this testnet is running on?
EDIT: I'm not looking for a way to configure which network truffle connects to. I'm trying to run truffle's development testnet on another port than 9545, which it takes by default. The reason is that it would make it easier to run the code on TestRPC as well.

Best Answer

You could also add another network to your truffle.js file. Something like this:

networks: {
  development: {
    host: "localhost",
    port: 9545,
    network_id: "*" // match any network
  },
  mynetwork: {
    host: "localhost",
    port: 8545,
    network_id: "*" // match any network
  },
}

Now you can run truffle migrate --network mynetwork. Like this, the contracts will be migrated to testrpc.

Related Topic