When I type testrpc cmd in console, client is working, then many many "eth_getBlockByNumber" appear, why ??? please give me some advice.

Then I open other window, type "truffle test" cmd, it can not work...

D:\www\smartContract\demo3>truffle test

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)
  • 2
    testrpc listen default port 8545, truffle develop port is 9545, I change 8545 to 9545 in truffle-config.js, but how can I change testrpc port ?
    – Kane Lu
    Jan 25, 2018 at 8:03

8 Answers 8


Here the problem is that you don't start your testrpc. You can start the testrpc in 2 way, one by running testrpc --account="" --gasPrice 0 or by runnig the geth client with the rpc option as geth --rpc. Also make sure that you configured your truffle.js file properly to accept the connection from 8545 port.

You can even use aurora as a client. In this case you should give the user and password combination with the rpc endpoint of the node in the web3 pack. You can find more about this in the official doc


truffle develop should be executed before deploying any contract.


Answer: Change truffle.js code as below or as per testrpc listening port. Change host number and port accordingly as sample below

module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*' // Match any network id

Answer2: Use below command line to change test rpc port to specific. Command Line:

$ testrpc < options >
-p or --port: Port number to listen on. Defaults to 8545.
-h or --hostname: Hostname to listen on. Defaults to Node's server.listen() default.


Check the parameters of your Ethereum client by:

Confirming whether the port displayed in your terminal is similar to the one in the "truffle-config.js" file. The 2 port numbers should be identical.

Worked for me.


Additionally I had to open port 8545 to localhost:

sudo iptables -A INPUT -p tcp -s localhost --dport 8545 -j ACCEPT

After running the Ethereum development server look in which port it is running.enter image description here

And the change in truffle-config.js as follows enter image description here


Open Ganache and check RPC SERVER HTTP://

Open truffle-config.js

Now change this truffle-config.js according to the above port no

// development: {
    //  host: "",     // Localhost (default: none)
    //  port: **7545**,            // Standard Ethereum port (default: none)
    //  network_id: "*",       // Any network (default: none)
    // },

Truffle is not working because you have to install Truffle and then you can test

Before installing truffle you have to install npm

Installing npm

$ install npm

Installing truffle

$ npm install truffle

Even if the problem is not solvable, then this is example :



Please Try it

Thank you!

  • "truffle init" can work, other cmd (truffle compile/test/server...) can not work,
    – Kane Lu
    Jan 24, 2018 at 8:56
  • Please all cmd close Then truffle init Jan 24, 2018 at 9:05
  • I recreate an empty folder demo7, then I type "trufflle init", it is ok, but truffle test/compile/... cmds still can not work, so strange...
    – Kane Lu
    Jan 24, 2018 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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