Error 502 bad gateway using mysql

Amado 2 years ago

I installed traccar with default database: works ok
Then I did changes in traccar.xml to enable mysql. Mysql service is active and running. tracker-server.log shows tables were created ok. Tracar service active and running.
After refresh login page shows error 502 bad gateway
I see several error In browsers's console starting with +> GET https://mydomain/styles.css (I just change my real domain by mydomain)
I suspect this has something to do with database.url entry in traccar.xml. Documentation says it should be set to localhost

What can be wrong?

Anton Tananaev 2 years ago

Why are you starting a new thread? Didn't you already have exactly the same problem?

Anton Tananaev 2 years ago
Amado 2 years ago

This is a new symptom. I already resolved the former problem , it was due to apache2 listening to the same port. I killed this process and make free port 80. Now only nginx is listening in port 80.
I opened a new thread because I wanted to focus in this new problem to avoid confusions

Anton Tananaev 2 years ago

How did you solve the original problem with the database lock? It had nothing to do with the apache or nginx.

Amado 2 years ago

I don't know why but after testing some solutions the login page stops responding completely (browser's says the "site is down")
Now with this 502 error I have new errors in tracker-server.log:

2023-08-06 15:48:29  INFO: HikariPool-1 - Starting...
2023-08-06 15:48:34 ERROR: HikariPool-1 - Exception during pool initialization. - Connection refused - ConnectException
(... < DatabaseModule:79 < <gener:-1 < *:-1 < ... < MainModule:123 < ...)
2023-08-06 15:48:34 ERROR: Main method error - Connection refused - ConnectException (... < DatabaseModule:79
 < <gener:-1 < *:-1 < ... < MainModule:123 < ...)
Anton Tananaev 2 years ago

Your database doesn't accept the connection, as you can see.

Connection refused

So either something is wrong with the database or with the database URL.

Amado 2 years ago

I'm really confused. traccar created the mysql tables successfully after making the changes in traccar.xml and rebooting.
Why it cannot connect from the web page?
Regarding <entry> "database.url" y tried changing the recommended value "localhost" with localhost:3306, also with "ipaddress" and ipaddress:3306, ipaddress is the ip of my vps. Problem still remains

Anton Tananaev 2 years ago

I don't know why, but that's the reason. Have you tried connecting to the database directly to test it?

Amado 2 years ago

While in the mysql's installation process, it ask to allow/disallow remote access. I set to "disallow" for security reasons so that only localhost can access it. Do you think that can be a problem for traccar?

Anton Tananaev 2 years ago

Definitely can. It probably means it doesn't listen on a network port, which is what Java driver uses.

Amado 2 years ago

I allowed connection to mysql from any ip. The problem is still there.
What ports do traccar need opened to work with mysql?

Anton Tananaev 2 years ago

Have you actually enabled it in MySQL itself?

Amado 2 years ago

I changed bind-address from 127.0.01. to 0.0.0.0 in mysql in mysqld.cnf (mysql configuration file), then I restarted mysql service

Amado 2 years ago

I could not fix the database lock with UNLOCK TABLES in mysql console. So I had to reinstall mysql and now it is working correctly