Database setting is not correct: dial tcp getsockopt: connection refused



Gogs version:
Operating system: Ubuntu 16.04 LTS
Database : MySQL 5.7.19-0ubuntu0.16.04.1 (Ubuntu)

I was trying to upgrade my GOGS docker image from 0.9.x.x to latest version.
I followed the instructions:

  • docker pull gogs/gogs
  • docker stop gogs
  • docker rm gogs
  • docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs

When I went to the url for gogs, I have the “Install Steps For First-time Run” page. Filled in the database settings as (except for pw, the rest are default settings) :
Database Type: Mysql
User: root
Password : *****
Database Name: gogs

When I clicked Install Gogs, I get the error message:
Database setting is not correct: dial tcp getsockopt: connection refused

When I tried from command line: mysql -u root -p -h
I was able to enter MySQL without any error.

Thanks for the help


Well, if Gogs says not able to connect, it is what exactly it means. I am not sure if you can connect to host MySQL instance inside a Docker container, people often start another container for MySQL specifically.


When I installed gogs the first time months ago, I do not have this issue. The MySQL server is on the host machine while gogs is in Docker container. Ad I have been using Gogs for a few months. I just decide to upgrade the docker image as specified by the posted instruction, and can’t understand why it does not work the 2nd time around.
Is the database setting saying that Gogs is trying to connect to MySQL via from inside the docker container?


It is possible!


Issue fixed. I managed to find my config setting from my previous GOGS install. Since I’m using the docker version of GOGS, instead of the MySQL host being, it should be since being the bridge gateway IP for the container.

My guess is that the default settings for first time install assumes that MySQL and GOGS are both installed on the host server.


I have the exactly same issue. But when I try It reports error:

Database setting is not correct: Error 1130: Host '' is not allowed to connect to this MariaDB server


I’m getting this error now, but my settings are for sqlite3 so I shouldn’t be getting this at all right?

git clone git@<redacted>:geekingreen/resin-electronjs-react.git
Cloning into 'resin-electronjs-react'...
Gogs: Internal error
Fail to get repository owner 'geekingreen': dial tcp getsockopt: connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

any help would be appreciated :smiley:


@geekingreen use absolute path for SQLite3 path.


Even setting the sqlite DB with an absolute path it fails. It’s important to note that everything else works, just not git via SSH. I can login via the web, I can clone repos using https and a generated token (since I have 2FA enabled) I have validated that my public keys have been added appropriately via the web interface. But for whatever reason it throws this error when attempting git over SSH


Figured it out, I had updated my install from using gogits/gogs to gogs/gogs and the command that was being run on ssh authentication was pointed to the old gogs executable. I had to update the git users .ssh/authorized_keys and replace command="/home/gogs/go/src/ serv key-18 --config='/home/gogs/go/src/'" with command="/home/gogs/go/src/ serv key-18 --config='/home/gogs/go/src/'". Hopefully this helps others that may run into this situation.