# How to configure port for alpha , zero and ratel

**URL:** <https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129>\
**Category:** Dgraph\
**Created:** [June 11, 2020, 1:04am UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129 "2020-06-11T01:04:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![questiondgraph](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/questiondgraph/32/3041_2.png) [@questiondgraph](https://discuss.dgraph.io/u/questiondgraph)\
**Post date:** [June 11, 2020, 1:04am UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/1 "2020-06-11T01:04:39Z")

</div>

I would like to configure the alpha, zero and ratel use different port.  
here is what i have tried

the dgraph version  
Draph version : v20.03.1  
Dgraph SHA-256 : cbd3c7fd96d08f6b78259a10e03d70ab85a4afd3c9a4c68daac6358fe84a4b6e  
Commit SHA-1 : c201611d6  
Commit timestamp : 2020-04-24 13:53:41 -0700  
Branch : HEAD  
Go version : go1.14.1

/usr/local/bin/dgraph zero --my “127.0.0.1:12001”  
from the terminal of zero , here is the log output  
…  
I0610 17:32:30.395100 50177 run.go:108] Setting up grpc listener at: 0.0.0.0:5080  
I0610 17:32:30.395608 50177 run.go:108] Setting up http listener at: 0.0.0.0:6080  
badger 2020/06/10 17:32:30 INFO: All 1 tables opened in 1ms  
…  
I0610 17:32:30.462085 50177 raft.go:702] Done applying conf change at 0x1  
I0610 17:32:30.462492 50177 pool.go:160] CONNECTING to localhost:7080  
W0610 17:32:30.462515 50177 pool.go:191] Shutting down extra connection to localhost:7080  
W0610 17:32:30.464759 50177 pool.go:254] Connection lost with localhost:7080. Error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = “transport: Error while dialing dial tcp [::1]:7080: connect: connection refused”  
…

/usr/local/bin/dgraph alpha --lru\_mb 4096 --my “127.0.0.1:11001” --zero “127.0.0.1:12001”  
from the terminal of alpha, the output is  
…  
I0610 17:48:40.687705 50235 groups.go:107] Current Raft Id: 0x1  
I0610 17:48:40.687849 50235 worker.go:96] Worker listening at address: [::]:7080  
I0610 17:48:40.691336 50235 run.go:480] Bringing up GraphQL HTTP API at 0.0.0.0:8080/graphql  
I0610 17:48:40.691387 50235 run.go:481] Bringing up GraphQL HTTP admin API at 0.0.0.0:8080/admin  
I0610 17:48:40.691443 50235 run.go:512] gRPC server started. Listening on port 9080  
I0610 17:48:40.691457 50235 run.go:513] HTTP server started. Listening on port 8080  
I0610 17:48:40.791031 50235 pool.go:160] CONNECTING to 127.0.0.1:12001  
W0610 17:48:40.792132 50235 pool.go:254] Connection lost with 127.0.0.1:12001. Error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = “transport: Error while dialing dial tcp 127.0.0.1:12001: connect: connection refused”  
I0610 17:48:45.692838 50235 query.go:123] Dgraph query execution failed : Dgraph query failed because Please retry again, server is not ready to accept requests  
I0610 17:48:45.692905 50235 admin.go:520] Error reading GraphQL schema: Dgraph query failed because Dgraph query failed because Please retry again, server is not ready to accept requests.  
I0610 17:48:50.693990 50235 query.go:123] Dgraph query execution failed : Dgraph query failed because Please retry again, server is not ready to accept requests  
…

for testing zero :  
if i do the localhost:12001/state , the page cannot be reached  
if i do the localhost:6080/state , it return the following  
{“counter”:“9”,“groups”:{“1”:{“members”:{“1”:{“id”:“1”,“groupId”:1,“addr”:“localhost:7080”,“leader”:true,“lastUpdate”:“1591819452”}},“tablets”:{“dgraph.graphql.schema”:{“groupId”:1,“predicate”:“dgraph.graphql.schema”},“dgraph.type”:{“groupId”:1,“predicate”:“dgraph.type”}},“checksum”:“3103359118597316741”}},“zeros”:{“1”:{“id”:“1”,“addr”:“localhost:5080”,“leader”:true}},“maxTxnTs”:“10000”,“maxRaftId”:“1”,“cid”:“748d8a6a-ddbc-47ca-bc0a-8eb1e21e6980”,“license”:{“maxNodes”:“18446744073709551615”,“expiryTs”:“1594411453”,“enabled”:true}}

for testing alpha  
if i do the localhost:11001, the page cannot be reached  
if i do the localhsot:8080, i get the following  
{“errors”:[{“message”:“No membership state found”,“extensions”:{“code”:“Error”}}]}

for ratel ,  
/usr/local/bin/dgraph-ratel -port 13001 -addr “[http://127.0.0.1:11001](http://127.0.0.1:11001)”  
in brwoser, [http://localhost:13001/?latest](http://localhost:13001/?latest) , it try to connect , it has “connected” check mark but with read color icon

should i use the --port\_offset for both alpha and zero? however, it doesn’t work as expected.

My goal is to organize the port that dgraph use.

Thanks…

---

<div class="post-metadata">

**Author:** ![dmai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/dmai/32/1254_2.png) [@dmai](https://discuss.dgraph.io/u/dmai)\
**Post date:** [June 11, 2020, 1:13am UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/2 "2020-06-11T01:13:48Z")

</div>

You can use the `--port_offset` flag to set some port that you want. It will always offset the internal-gRPC, external-gRPC, and HTTP ports by 100.

For example:

- Alpha with `--port_offset=0` would bind ports 7080, 8080, and 9080.
- Alpha with `--port_offset=100` would bind ports 7180, 8180, and 9180.

If you need to control the specific ports you expose, you can use the default port mapping and rely on Docker’s port-mapping to map the ports to specific ports, e.g., `docker run -p 11001:7080 ...`.

---

<div class="post-metadata">

**Author:** ![questiondgraph](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/questiondgraph/32/3041_2.png) [@questiondgraph](https://discuss.dgraph.io/u/questiondgraph)\
**Post date:** [June 11, 2020, 5:28am UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/3 "2020-06-11T05:28:19Z")

</div>

thanks for your reply. I have tried the port\_offset, however, zero gets into the infinity loop. Then, just find out that you need to start zero first then alpha… :). (i am not running the docker)

We cannot configure individual port unless we download the source code and change&compile it from [dgraph/x.go at master · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/blob/master/x/x.go) ?

Thanks

---

<div class="post-metadata">

**Author:** ![Neeraj](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/neeraj/32/3104_2.png) [@Neeraj](https://discuss.dgraph.io/u/Neeraj)\
**Post date:** [June 11, 2020, 1:55pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/4 "2020-06-11T13:55:24Z")

</div>

You should be able to configure individual port even without the source code. Can you please share the error logs and the command that you’re using to run `dgraph zero` and `dgraph alpha`?

---

<div class="post-metadata">

**Author:** ![questiondgraph](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/questiondgraph/32/3041_2.png) [@questiondgraph](https://discuss.dgraph.io/u/questiondgraph)\
**Post date:** [June 11, 2020, 7:10pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/5 "2020-06-11T19:10:06Z")

</div>

uhm… what’s the option to configure the individual port? as far as i know from dgraph zero/alpha --help, it only provides port\_offset=xxx option to add xxx to those port instead of change individual one.  
Thank you

---

<div class="post-metadata">

**Author:** ![dmai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/dmai/32/1254_2.png) [@dmai](https://discuss.dgraph.io/u/dmai)\
**Post date:** [June 11, 2020, 9:54pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/6 "2020-06-11T21:54:47Z")

</div>

There’s only the port offset flag. To simplify the config, Dgraph only exposes a single option for an offset.

You could use Docker if you have more specific port needs. See the `ports:` field below where the ports are exposed externally as to 12001, 12002, etc.

```auto
version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 12001:5080
      - 12002:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080
  alpha:
    image: dgraph/dgraph:latest
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 11001:8080
      - 11002:9080
    restart: on-failure
    command: dgraph alpha --my=alpha:7080 --lru_mb=2048 --zero=zero:5080
  ratel:
    image: dgraph/dgraph:latest
    ports:
      - 13001:8000
    command: dgraph-ratel

volumes:
  dgraph:

```

---

<div class="post-metadata">

**Author:** ![questiondgraph](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/questiondgraph/32/3041_2.png) [@questiondgraph](https://discuss.dgraph.io/u/questiondgraph)\
**Post date:** [June 11, 2020, 10:37pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/7 "2020-06-11T22:37:05Z")

</div>

thanks… i will keep that in mind if we plan to run in docker, thanks…

---

<div class="post-metadata">

**Author:** ![Paras](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/paras/32/2768_2.png) [@Paras](https://discuss.dgraph.io/u/Paras)\
**Post date:** [June 11, 2020, 11:41pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/8 "2020-06-11T23:41:43Z")

</div>

It seems the `--my` option is not implemented correctly. We are tracking a issue on this. Current recommendation is to use `port_offset` flag.

---

<div class="post-metadata">

**Author:** ![gmlewis](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/gmlewis/32/6300_2.png) [@gmlewis](https://discuss.dgraph.io/u/gmlewis)\
**Post date:** [February 18, 2021, 5:30pm UTC](https://discuss.dgraph.io/t/how-to-configure-port-for-alpha-zero-and-ratel/7129/9 "2021-02-18T17:30:37Z")

</div>

> [@questiondgraph](#):
>
> thanks… i will keep that in mind if we plan to run in docker, thanks…

@questiondgraph - were you ever able to run DGraph locally with your own set of ports?

I’m writing a Vue3 web app locally, running on port 8080, and would like it to talk to DGraph locally, but don’t want to run Docker. I keep getting the DGraph infinite error loop no matter what `--port_offset` values I try.
