0

How is the truffle port set when one runs truffle unbox react and then truffle develop ?

The documentation states that the default port is 9545 (https://trufflesuite.com/docs/truffle/getting-started/using-truffle-develop-and-the-console.html), but the port specified in the downloaded truffle-config.js is 8545, which is supposed to be the default port when Ganache is the client.

I also noticed that the default port specified here :

https://github.com/truffle-box/react-box/blob/master/client/src/getWeb3.js

is 8545:

https://github.com/truffle-box/react-box/blob/c33a70f57559c0040f7109f9db498a0f83187776/client/src/getWeb3.js#L26

 // Fallback to localhost; use dev console port by default...
      else {
         const provider = new Web3.providers.HttpProvider(
          "http://127.0.0.1:8545"
      );

Can someone help shed light on this ?

2 Answers 2

1

truffle develop spins up a specially configured ganache to interact with the truffle console. This is on purpose run on a different port (9545) to not conflict with the default ganache port 8545, see https://github.com/trufflesuite/ganache-cli-archive).

1
  • Thx, I didn't know it ran ganache internally. Do you know why when I run truffle develop it states : Truffle Develop started at http://127.0.0.1:8545/ instead of : Truffle Develop started at http://127.0.0.1:9545/ ?
    – femibyte
    Commented Jan 17, 2022 at 18:17
0

Ok, so the way I got it to start up on port 9545 was to modify the truffle-config.js. The default file generated when I ran truffle unbox react had these lines:

 networks: {
   develop: {
     port: 8545
  }
 }

Contrary to the documentation, it does seem like truffle develop results in this file being read.

I changed the network name to development:

 networks: {
   development: {
     port: 8545
  }
 }

And now when I run truffle develop it starts up on port 9545.

Truffle Develop started at http://127.0.0.1:9545/

It looks like the Truffle documentation may be a bit outdated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.