[Ethereum] Timeout error on deploying to Rinkeby from truffle migrate


I have just finished the CryptoZombies tutorials, and was trying to deploy the file following their instructions to the Rinkeby network. But I keep getting this timeout error and am lost on how to proceed.

$truffle migrate --network rinkeby

Compiling your contracts...
> Everything is up to date, there is nothing to compile.

        throw new Error(errorMessage);
Error: There was a timeout while attempting to connect to the network.
       Check to see that your provider is valid.
       If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
    at Timeout._onTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

My truffle-config.js is as follows:

const HDWalletProvider = require("truffle-hdwallet-provider");

const mnemonic = "depth invite butter ...";

module.exports = {

  networks: {

    mainnet: {
      provider: function () {

        return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/YOUR_TOKEN")
      network_id: "1"

    rinkeby: {

      provider: function () {

        return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/YOUR_TOKEN")

      network_id: 4

Best Answer

I have fixed this problem by setting networkCheckTimeout as 10000 before setting provider in truffle-config.js.

networks: {
  bsctest: {
      networkCheckTimeout: 10000, 
      provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545/`),
      network_id: 97,
      confirmations: 10,
      timeoutBlocks: 2000,
      skipDryRun: true
Related Topic