gogs: Fail to initialize ORM engine: migrate: sync
Hi! I’m using a MySQL database. I’m not sure what changed, but now it shuts down after some time. I get this error in gogs.log
:
2016/02/04 13:35:11 [...s/routers/install.go:70 GlobalInit()] [E] Fail to initialize ORM engine: migrate: sync: dial tcp 127.0.0.1:3306: getsockopt: connection refused
This is my database configuration
[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gogs
USER = gogs
PASSWD = ******
SSL_MODE = disable
PATH = data/gogs.db
Any idea what could cause this error? And I’m also unsure about the PATH = data/gogs.db
part since I’m using a MySQL server it shouldn’t need the path to a database file?
Thanks
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 23 (9 by maintainers)
. I fixed this on Debian Jessie by adding
After=mysql.service
to gogs.service.Hi, I had this problem when the server was rebooted. In my case the problem was Gogs starting before Mysql.
My server is running Debian 8 (Jessie) so modifying
/etc/init.d/gogs
Required-Start and adding mysql to it has fixed it:# Required-Start: $syslog $network mysql
and then run
insserv -d
So for the op the problem might be with Mysql rather than Gogs.
@DanielGilbert The
After=
line alone should be adequate according to this systemd man page:(I also had this issue with Debian 8 – the resaon was that I had
mysqld.service
instead ofmysql.service
in the systemd unit. 😉)Just to add a note for future reference.
I am running Gogs version 0.9.20.0404 on centos7 with exact same issue of gogs failed to connect to mysql. Following is my work around script.
$vim /etc/systemd/system/gogs.service Append
mysql.service
toAlfter=
line.Is it worth it to add a comment in
gogs.service
highlighting themysqld
/mysql
mess? It’s a not so obvious source of errors.My 2c, on Ubuntu 14.04 with packager.io Gogs both MySQL and Gogs are upstart services. So:
/etc/init/gogs.conf
and change:
into
else, Gogs will fail to start after server reboot.