How to change username and password using command line flags?

The default username is “admin” and password is “password”. I want to change them. Was trying to use something like below but getting error. What should be the actual answer?

./nakama --console.username user --console.password pass

Hello @Shahariar_Ashik,

Could you provide the error you’re getting please?

fatal: [nakama]: FAILED! => {"changed": true, "cmd": "./nakama --console.username ashik --console.password ashik1234", "delta": "0:00:00.020524", "end": "2022-11-17 14:07:16.659982", "msg": "non-zero return code", "rc": 1, "start": "2022-11-17 14:07:16.639458", "stderr": "", "stderr_lines": [], "stdout": "{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:313\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"console.signing_key\"}\n{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:317\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"socket.server_key\"}\n{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:321\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"session.encryption_key\"}\n{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:325\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"session.refresh_encryption_key\"}\n{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:329\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"runtime.http_key\"}\n{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"v3/main.go:104\",\"msg\":\"Nakama starting\"}\n{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:105\",\"msg\":\"Node\",\"name\":\"nakama\",\"version\":\"3.14.0+e2df3a29\",\"runtime\":\"go1.19.2\",\"cpu\":1,\"proc\":1}\n{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:106\",\"msg\":\"Data directory\",\"path\":\"/tmp/data\"}\n{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:125\",\"msg\":\"Database connections\",\"dsns\":[\"root@localhost:26257\"]}\n{\"level\":\"fatal\",\"ts\":\"2022-11-17T14:07:16.658Z\",\"caller\":\"server/db.go:81\",\"msg\":\"Error pinging database\",\"error\":\"failed to connect to `host=localhost user=root database=nakama`: dial error (dial tcp 127.0.0.1:26257: connect: connection refused)\"}", "stdout_lines": ["{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:313\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"console.signing_key\"}", "{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:317\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"socket.server_key\"}", "{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:321\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"session.encryption_key\"}", "{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:325\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"session.refresh_encryption_key\"}", "{\"level\":\"warn\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"server/config.go:329\",\"msg\":\"WARNING: insecure default parameter value, change this for production!\",\"param\":\"runtime.http_key\"}", "{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.656Z\",\"caller\":\"v3/main.go:104\",\"msg\":\"Nakama starting\"}", "{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:105\",\"msg\":\"Node\",\"name\":\"nakama\",\"version\":\"3.14.0+e2df3a29\",\"runtime\":\"go1.19.2\",\"cpu\":1,\"proc\":1}", "{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:106\",\"msg\":\"Data directory\",\"path\":\"/tmp/data\"}", "{\"level\":\"info\",\"ts\":\"2022-11-17T14:07:16.657Z\",\"caller\":\"v3/main.go:125\",\"msg\":\"Database connections\",\"dsns\":[\"root@localhost:26257\"]}", "{\"level\":\"fatal\",\"ts\":\"2022-11-17T14:07:16.658Z\",\"caller\":\"server/db.go:81\",\"msg\":\"Error pinging database\",\"error\":\"failed to connect to `host=localhost user=root database=nakama`: dial error (dial tcp 127.0.0.1:26257: connect: connection refused)\"}"]}

The error is due to the database not being reachable, not because of the console params. Please make sure the db address is correct and that the db is running and reachable by Nakama.

./nakama --console.username user --console.password pass
./nakama --console.username user --console.password pass --database.address username:password@address:port/dbname

what is the actual command?

If I use command like below

./nakama --console.username user --console.password pass --database.address username:password@address:port/dbname

I get the below error.

"msg\":\"API server listener failed to start\",\"error\":\"listen tcp :7349: bind: address already in use\"}"]}

The error indicates you either have an instance of Nakama already running locally or something else that’s binding to the 7349 port. Terminate the culprit process and retry.