Error connecting to mysql database during installation #562

Closed
opened 2025-11-02 03:28:14 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @ADmad on GitHub (Mar 22, 2017).

  • Git version: v1.1.0
  • Operating system: ubuntu 16.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

When trying to install gitea i am getting the following error Database setting is not correct: dial tcp: missing port in address localhost. I used host localhost with proper credentials.

I also tried using host as localhost:3306 which results in error Database setting is not correct: dial tcp 127.0.0.1:3306: getsockopt: connection refused

Originally created by @ADmad on GitHub (Mar 22, 2017). - Git version: v1.1.0 - Operating system: ubuntu 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description When trying to install gitea i am getting the following error `Database setting is not correct: dial tcp: missing port in address localhost`. I used host `localhost` with proper credentials. I also tried using host as `localhost:3306` which results in error `Database setting is not correct: dial tcp 127.0.0.1:3306: getsockopt: connection refused`
GiteaMirror added the type/question label 2025-11-02 03:28:14 -06:00
Author
Owner

@ADmad commented on GitHub (Mar 22, 2017):

After setting bind-address: 127.0.0.1 in mysql server config I was able to get the installation working with host localhost:3306.

Just using host localhost still gives the error message reported above. It's a bit strange specifying the port is necessary even though it's default port.

@ADmad commented on GitHub (Mar 22, 2017): After setting `bind-address: 127.0.0.1` in mysql server config I was able to get the installation working with host `localhost:3306`. Just using host `localhost` still gives the error message reported above. It's a bit strange specifying the port is necessary even though it's default port.
Author
Owner

@strk commented on GitHub (Mar 22, 2017):

Could anyone please reopen this ? We want people to be able to set Gitea to still use unix sockets to connect to mysql.

@strk commented on GitHub (Mar 22, 2017): Could anyone please reopen this ? We want people to be able to set Gitea to still use unix sockets to connect to mysql.
Author
Owner

@ADmad commented on GitHub (Mar 22, 2017):

Reopening the issue on @strk's request.

@ADmad commented on GitHub (Mar 22, 2017): Reopening the issue on @strk's request.
Author
Owner

@muhfaris commented on GitHub (Dec 18, 2017):

i try to run go-gitea through docker-compose, following the tutorial Installation with docker.
and get error as follow:

Database setting is invalid: dial tcp 127.0.0.1:3306: getsockopt: connection refused

change to localhost, not work

docker compose is running

     Name                   Command               State                   Ports                 
------------------------------------------------------------------------------------------------
gitea_db_1       docker-entrypoint.sh mysqld      Up      3306/tcp                              
gitea_server_1   /usr/bin/entrypoint /bin/s ...   Up      0.0.0.0:222->22/tcp,                  
                                                          0.0.0.0:3000->3000/tcp 

can you help me @ADmad @strk ?
thanks

@muhfaris commented on GitHub (Dec 18, 2017): i try to run go-gitea through docker-compose, following the tutorial [Installation with docker](https://docs.gitea.io/en-us/install-with-docker/#mysql-database). and get error as follow: ` Database setting is invalid: dial tcp 127.0.0.1:3306: getsockopt: connection refused ` change to `localhost`, not work docker compose is running ``` Name Command State Ports ------------------------------------------------------------------------------------------------ gitea_db_1 docker-entrypoint.sh mysqld Up 3306/tcp gitea_server_1 /usr/bin/entrypoint /bin/s ... Up 0.0.0.0:222->22/tcp, 0.0.0.0:3000->3000/tcp ``` can you help me @ADmad @strk ? thanks
Author
Owner

@lunny commented on GitHub (Dec 20, 2017):

@muhfaris you should map mysql port to 3306

@lunny commented on GitHub (Dec 20, 2017): @muhfaris you should map mysql port to 3306
Author
Owner

@muhfaris commented on GitHub (Dec 20, 2017):

@lunny thanks for reply
but isn't work,
i try to change from localhost or 127.0.0.1 to ip address from db container.
to get ip from db container use command sudo docker-compose exec db ifconfig

@muhfaris commented on GitHub (Dec 20, 2017): @lunny thanks for reply but isn't work, i try to change from `localhost` or `127.0.0.1` to ip address from db container. to get ip from db container use command ` sudo docker-compose exec db ifconfig`
Author
Owner

@Wilkolicious commented on GitHub (Jul 19, 2018):

If you're using docker-compose, you need to reference the host as the service name from within your docker-compose.yml.

So if you copy-pasta'd the config from the instructions, your database will be at: db:3306.

If the database was started with the docker-compose setup as documented above please note that db must be used as the database hostname.

See: https://docs.gitea.io/en-us/install-with-docker/#install

@Wilkolicious commented on GitHub (Jul 19, 2018): If you're using `docker-compose`, you need to reference the host as the service name from within your `docker-compose.yml`. So if you copy-pasta'd the config from the instructions, your database will be at: `db:3306`. > If the database was started with the docker-compose setup as documented above please note that db must be used as the database hostname. See: https://docs.gitea.io/en-us/install-with-docker/#install
Author
Owner

@ghost commented on GitHub (Oct 10, 2018):

I have installed this via docker and set my database to be gitea-database. I've referenced this as suggested as gitea-database:3306 in docker-compose.yaml.

When I run the install script I get the following error:

The database settings are invalid: dial tcp: lookup gitea-database on 127.0.0.11:53: no such host

Edit:

I had neglected to add my network to the database host. ignore this comment.

@ghost commented on GitHub (Oct 10, 2018): I have installed this via docker and set my database to be `gitea-database`. I've referenced this as suggested as `gitea-database:3306` in `docker-compose.yaml`. When I run the install script I get the following error: >The database settings are invalid: dial tcp: lookup gitea-database on 127.0.0.11:53: no such host Edit: I had neglected to add my network to the database host. ignore this comment.
Author
Owner

@tester0077 commented on GitHub (Aug 17, 2019):

I have just run into the very same issue after an installation from a binary. Docker is installed, but I would expect that installing it directly would not involve it in any way.
FWIW, I am trying to install it on an OpenMediaVault machine using ShellInABox,
The signon says:
Linux MyNAS 4.19.0-0.bpo.2-amd64 #1 SMP Debian 4.19.16-1~bpo9+1 (2019-02-07) x86_64
\Neither localhost, nor 127.0.0.1 not the box's real IP address make any difference, other than in the response IP:port string
Curiously, the ShellInABox screen does not look like there were any errors, though I am not really sure what I should expect

@tester0077 commented on GitHub (Aug 17, 2019): I have just run into the very same issue after an installation from a binary. Docker is installed, but I would expect that installing it directly would not involve it in any way. FWIW, I am trying to install it on an OpenMediaVault machine using ShellInABox, The signon says: Linux MyNAS 4.19.0-0.bpo.2-amd64 #1 SMP Debian 4.19.16-1~bpo9+1 (2019-02-07) x86_64 \Neither localhost, nor 127.0.0.1 not the box's real IP address make any difference, other than in the response IP:port string Curiously, the ShellInABox screen does not look like there were any errors, though I am not really sure what I should expect
Author
Owner

@ElTimablo commented on GitHub (Oct 12, 2020):

I'm running into this issue as well using docker-compose. I was able to get something to happen by passing it its own IP address, but that time the page timed out while the database churned in the background.

@ElTimablo commented on GitHub (Oct 12, 2020): I'm running into this issue as well using docker-compose. I was able to get _something_ to happen by passing it its own IP address, but that time the page timed out while the database churned in the background.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#562