Truffle does not add "networks" to build/contracts/contract.json files after migration.

enter image description here

Versions running

  • Truffle v4.0.1 (core: 4.0.1)
  • Solidity v0.4.18 (solc-js)
  • EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)
  • MacOS High Sierra 10.13.1

What I have tried already

  1. Downgrading Truffle: I have tried to downgrade from Truffle version 4.0.4 to version 4.0.0 and then to 4.0.1 to test if it has something to do with Truffle version, but unfortunately I get the same problem.

truffle.js file looks like this:

module.exports = {
   networks: {
     development: {
       host: "localhost",
       port: 8545,
       network_id: "*" // Match any network id
  1. I also tried to run over port 9545 with $ truffle develop, but got the same problem.

Error message

When I run $ truffle test I get the following error message:

Error: TestContract has not been deployed to detected network (network/artifact mismatch)

What does work

When I run $ truffle migrate --reset, my build/contracts/Migrations.json file does have the networks specified like:

"networks": {
    "1516203204392": {
      "events": {},
      "links": {},
      "address": "0xa10a9e84eb3ef0bf7ebc1b6337c20031b5a80e69"
  • Can you also add your file(s) from /migrations? Jan 17, 2018 at 16:07
  • 1
    What is in your migrateion folder? Is there 2_deploy_contracts.js or some other code which is running to migrate your contracts to blockchain? Jan 18, 2018 at 9:46
  • @RomanFrolov the 1_initial_migrations.js file, but I found out that I did not deploy my contract in migrations file for some stupid reason. But now I have the following problem.. ethereum.stackexchange.com/questions/36690/…
    – Robbert
    Jan 18, 2018 at 9:49
  • truffle migrate --reset helps me. Just note here so anybody else meet problem can use that :D
    – hqt
    May 19, 2018 at 13:12
  • I had the same problem but in my case I had forgotten to add the migration files to my root directory, and adding them solved my problem Feb 19, 2022 at 19:00

2 Answers 2


I had the same issue,

On closer observation, the issue is with 2_deploy_contracts.js. When you are running truffle migrate --reset Keep an eye on the text Saving artifacts... And also take a look at after which contract deployment this appears, and after this is the problem in the migration file.

I had some async/awaits in there and apparently the code executes but writing the artifacts has some time constraints and runs after the third contract deployment therefore only 3 of my contracts had networks populated and rest empty.

Hope this helps someone doing such silly mistakes like me.

  • 1
    truffle migrate --reset helps me. Just note here so anybody else meet problem can use that :D
    – hqt
    May 19, 2018 at 13:12

In my case, it was async/await calls in the migration that I forgot to add await on them. Because of that the migration stalled/stuck forever.

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.