Logs:
Oct 27 04:25:22 localhost traccar[1159]: #011... 16 more
Oct 27 04:25:22 localhost systemd[1]: traccar.service: Main process exited, code=exited, status=1/FAILURE
Oct 27 04:25:22 localhost systemd[1]: traccar.service: Failed with result 'exit-code'.
Oct 27 04:25:27 localhost kernel: [ 166.153714] [UFW BLOCK] IN=eth0 OUT= MAC=f2:3c:92:29:c5:49:e4:c7:22:1f:22:c1:08:00 SRC=139.162.130.188 DST=172.105.81.245 LEN=40 TOS=0x00 PREC=0x00 TTL=254 ID=9114 PROTO=TCP SPT=61000 DPT=59262 WINDOW=1024 RES=0x00 SYN URGP=0
Oct 27 04:25:32 localhost systemd[1]: traccar.service: Scheduled restart job, restart counter is at 9.
Oct 27 04:25:32 localhost systemd[1]: Stopped traccar.
Oct 27 04:25:32 localhost systemd[1]: Started traccar.
Oct 27 04:25:34 localhost traccar[1199]: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Oct 27 04:25:40 localhost traccar[1199]: Exception in thread "main" java.lang.RuntimeException: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.Main.run(Main.java:163)
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.Main.main(Main.java:110)
Oct 27 04:25:40 localhost traccar[1199]: Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Oct 27 04:25:40 localhost traccar[1199]: #011at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:595)
Oct 27 04:25:40 localhost traccar[1199]: #011at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:581)
Oct 27 04:25:40 localhost traccar[1199]: #011at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
Oct 27 04:25:40 localhost traccar[1199]: #011at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.database.DataManager.initDatabase(DataManager.java:139)
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.database.DataManager.<init>(DataManager.java:89)
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.Context.init(Context.java:292)
Oct 27 04:25:40 localhost traccar[1199]: #011at org.traccar.Main.run(Main.java:137)
Oct 27 04:25:40 localhost traccar[1199]: #011... 1 more
The error message is pretty clear:
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Bellow is my configuration...
and the log says:
Oct 27 04:25:34 localhost traccar[1199]: Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Is this could be the problem?
cat > /opt/traccar/conf/traccar.xml << EOF
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<entry key="config.default">./conf/default.xml</entry>
<entry key='database.driver'>com.mysql.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>root</entry>
<entry key='database.password'>root</entry>
</properties>
EOF
I don't think so. It's deprecated, but still usable. Try connecting to your database using mysql
command line tool. Make sure you do it via a TCP connection.
Dear Anton,
Thanks for your prompt response. I fixed the DB issue and now it is connected. i used this config.
I guess I missed the db port: 3306
Regards,
Elfatih
<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://[HOST]:3306/[DATABASE]?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>[USER]</entry>
<entry key='database.password'>[PASSWORD]</entry>
Port 3306 is the default. Usually you don't need to specify it. There must have been some other issue.
I had another error I guess it is releated to the firewall see the log what do you think?:
Oct 27 06:47:12 localhost systemd[1]: traccar.service: Main process exited, code=exited, status=1/FAILURE
Oct 27 06:47:12 localhost systemd[1]: traccar.service: Failed with result 'exit-code'.
xOct 27 06:47:17 localhost kernel: [ 127.384090] [UFW BLOCK] IN=eth0 OUT= MAC=f2:3c:92:29:c5:49:50:XXXXXXXX SRC=XX.XX.XX.XX DST=xx.xx.xx.xx LEN=44 TOS=0x08 PREC=0x20 TTL=111 ID=37934 PROTO=TCP SPT=6195 DPT=666 WINDOW=29200 RES=0x00 SYN URGP=0
I think you should check Traccar logs for the details.
Logs: