How to set host and port with dfx start on dfx 0.12

I’ve upgraded to dfx 0.12.0-beta.3 and it seems like the port of the replica is changing randomly. That’s a big problem because our Node.js tests have to specify a host and port, which used to be 127.0.0.1:8000.

How do we set the port when using dfx start? Also this is kind of a major change in behavior, I’m not sure it should just be pushed out with dfx 0.12

Apparently the networks property in dfx.json is what I want. But this isn’t working. Here is my dfx.json:

{
    "canisters": {
        "azle": {
            "type": "custom",
            "build": "npx azle azle",
            "root": "canisters/azle",
            "ts": "canisters/azle/index.ts",
            "candid": "canisters/azle/index.did",
            "wasm": "target/wasm32-unknown-unknown/release/azle.wasm",
            "declarations": {
                "output": "dfx_generated/azle"
            }
        },
        "motoko": {
            "type": "motoko",
            "main": "canisters/motoko/main.mo",
            "declarations": {
                "output": "dfx_generated/motoko"
            }
        },
        "rust": {
            "type": "rust",
            "package": "rust",
            "candid": "canisters/rust/src/lib.did",
            "declarations": {
                "output": "dfx_generated/rust"
            }
        }
    },
    "networks": {
        "local": {
            "bind": "127.0.0.1:8000",
            "type": "ephemeral"
        }
    }
}

But running dfx start is still using the wrong port:

Running dfx start for version 0.12.0-beta.3
Using project-specific network 'local' defined in /home/lastmjs/development/azle/examples/query/dfx.json
WARN: Project-specific networks are deprecated and will be removed after February 2023.
Dashboard: http://localhost:36805/_/dashboard

Nevermind, the dashboard port was throwing me off. Instead of a local networks property, it is also possible to use the REPLICA_PORT environment variable like this: REPLICA_PORT=8000 dfx start --clean