Nakama "migrate up" error


I cannot do Nakama migration on freshly installed Debian 10 :frowning:

I have installed Cockroach according to guide (successfully ran the demo):

I have copied Nakama binary from the repository, as suggested:

Then I continued following the guide:
but got stuck on point 4:

username:~$ nakama migrate up
{"level":"info","ts":"2021-01-23T22:33:47.229+0100","caller":"migrate/migrate.go:139","msg":"Database connection","dsn":"postgresql://root@localhost:26257?sslmode=disable"}
{"level":"fatal","ts":"2021-01-23T22:33:47.232+0100","caller":"migrate/migrate.go:147","msg":"Error pinging database","error":"dial tcp connect: connection refused"}

I also tried adding the address manually:

username:~$ nakama migrate up --database.address root@cockroachdb:26257
{"level":"info","ts":"2021-01-23T23:09:35.088+0100","caller":"migrate/migrate.go:139","msg":"Database connection","dsn":"postgresql://root@cockroachdb:26257?sslmode=disable"}
{"level":"fatal","ts":"2021-01-23T23:09:40.118+0100","caller":"migrate/migrate.go:147","msg":"Error pinging database","error":"dial tcp: lookup cockroachdb on <MY_IP>:53: no such host"}

I don’t want to use Postgres, I would like to use Cockroach, as the guide suggests.
Can someone check what’s wrong here?
I think I did not skip any steps.

Could it be due to “postgres” prefix being hardcoded:
line: 121
rawURL := fmt.Sprintf("postgresql://%s", ms.dbAddress)

Thank you,

Please confirm that a cockroachDB instance is running using cockroach node command at cockroach node | CockroachDB Docs , or docker container ps if you are using multi-container solution to run nakama.


I have tested the docker container solution and it works.
Now I don’t know how to run the setup without docker, can someone please direct me to a guide or a book?

When I run “cockroach node” I get to the command interface asking me to chose a command… I think it does not end there.

Check the link I provided with the cockroach node command.

First of all, you have to set up an instance of CockroachDB. Take a look at Starting a single node. Of course, I am assuming that you want a single node. For starting a cluster of cockroach nodes, consult its documentation.

Basically, in order to start a cockroach node, you have to choose between two options: secure and insecure mode. The naming is self-explanatory. Use insecure mode for only testing and dev purposes.

Now you have to remove the part which instantiates a cockroach DB container from your docker-compoose.yml file. Moreover, you have to provide the address of the cockroach instance as the parameter for --database.address in your docker-compose file in this format root@{IP_ADDRESS}:26257. This was the case with connecting to an insecure cockroach instance.

Please refer to answers that Novabyte and me provided in Migrating to a secure cockroach node to run a separate, secure instance of cockroach DB.


Thank you Mahdad-Baghani, now I think that maybe I am going too fast with this.
I should probably get used to working with docker instance that has Nakama and Cockroach (in an insecure mode) bundled already, before switching to those advanced features.

1 Like

That’s exactly what I did. I didn’t move to a separate instance of cockroach DB until we wanted to do a closed test of our client and netcode; and I felt the need to separate the database due to some CPU spikes on the server which were caused by cockroachdb garbage collection. Increase in CPU usage over time - #26 by novabyte

@Mahdad-Baghani I think “allegedly” is an unnecessary choice of words where the word theorized would have worked better. Especially since you’ve not followed up with continued concerns/complaints about the performance of the server since.

I totally agree; That’s why I edited my reply. I actually thought that allegedly is synonym to “apparently” or “evidently”, hence the link to your answer as the backup :slight_smile: . I apologize for my poor choice of words. But I believe that you replied to an unedited version of my reply.

1 Like

@Mahdad-Baghani No worries. It’s a bit of a tangent to the original discussion but since you separated out the database and game server hardware do you still see CPU hotspots?

1 Like

Fortunately, no; that seems to have solved the CPU spikes.

Perfect. That’s good news @Mahdad-Baghani thanks :pray:

1 Like