Git operations over ssh gives "Gitea: Internal error" and "Failed to get repository: dial tcp 127.0.0.1:3306: connect: connection refused" #1843

Closed
opened 2025-11-02 04:14:53 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @hak8or on GitHub (Jun 1, 2018).

  • Gitea version (or commit ref): 1.4.1
  • Git version: 2.17.1
  • Operating system: Arch
  • 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

After updating (I didn't keep track of the previous version) I am unable to do any git pull/push/fetch on any of my repositories over ssh. I am able to do git operations over http for some reason though. The web GUI works fine, and I am able to access all my repositories and create repositories through the web GUI as well.

I am also puzzled as to why the error mentions connecting even though I am using sqlite3, not postgres/mysql/etc.

Only git operations over SSH don't seem to work.

For example:

λ git clone gitea@gitea.hak8or.com:hak8or/foo.git
Cloning into 'foo'...
Gitea: Internal error
Failed to get repository: dial tcp 127.0.0.1:3306: connect: connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
λ git clone http://gitea.hak8or.com/hak8or/foo.git
Cloning into 'foo'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.

I can access gitea via ssh though:

λ ssh gitea@gitea.hak8or.com
PTY allocation request failed on channel 0
Hi there, You've successfully authenticated, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
Connection to gitea.hak8or.com closed.

app.ini

APP_NAME = Hak8or Home Repos
RUN_USER = gitea
RUN_MODE = prod

[repository]
ROOT = /var/lib/gitea/repos

[server]
DOMAIN           = gitea.hak8or.com
PROTOCOL         = http
ROOT_URL         = %(PROTOCOL)s://%(DOMAIN)s
HTTP_PORT        = 3900
SSH_DOMAIN       = gitea.hak8or.com
STATIC_ROOT_PATH = /var/lib/gitea/

[database]
DB_TYPE             = sqlite3
PATH                = /var/lib/gitea/data/gitea.db

[security]
INSTALL_LOCK   = true
SECRET_KEY     = ---removed---
INTERNAL_TOKEN = ---removed---

[log]
ROOT_PATH = /var/log/gitea/
LEVEL     = Trace

Logs

I do not see any log updates via journalctl -u gitea but sshd does see the attempt.

[root@Gitea ~]# journalctl -u sshd --since "-1 minute" -f
-- Logs begin at Wed 2018-05-30 19:53:01 UTC. --
Jun 01 02:33:27 Gitea sshd[14227]: Accepted publickey for gitea from 192.168.1.1 port 7183 ssh2: RSA SHA256:uNQY0bMlMR5K8OULv9HtQZwCou8NUd0ULoVIW6mjQiI
Jun 01 02:33:27 Gitea sshd[14227]: pam_unix(sshd:session): session opened for user gitea by (uid=0)
Jun 01 02:33:28 Gitea sshd[14227]: pam_unix(sshd:session): session closed for user gitea
Originally created by @hak8or on GitHub (Jun 1, 2018). - Gitea version (or commit ref): 1.4.1 - Git version: 2.17.1 - Operating system: Arch - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description After updating (I didn't keep track of the previous version) I am unable to do any git pull/push/fetch on any of my repositories over ssh. I am able to do git operations over http for some reason though. The web GUI works fine, and I am able to access all my repositories and create repositories through the web GUI as well. I am also puzzled as to why the error mentions connecting even though I am using sqlite3, not postgres/mysql/etc. Only git operations over SSH don't seem to work. For example: ```bash λ git clone gitea@gitea.hak8or.com:hak8or/foo.git Cloning into 'foo'... Gitea: Internal error Failed to get repository: dial tcp 127.0.0.1:3306: connect: connection refused fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` ```bash λ git clone http://gitea.hak8or.com/hak8or/foo.git Cloning into 'foo'... remote: Counting objects: 5, done. remote: Compressing objects: 100% (4/4), done. remote: Total 5 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. ``` I can access gitea via ssh though: ```bash λ ssh gitea@gitea.hak8or.com PTY allocation request failed on channel 0 Hi there, You've successfully authenticated, but Gitea does not provide shell access. If this is unexpected, please log in with password and setup Gitea under another user. Connection to gitea.hak8or.com closed. ``` ## app.ini ``` APP_NAME = Hak8or Home Repos RUN_USER = gitea RUN_MODE = prod [repository] ROOT = /var/lib/gitea/repos [server] DOMAIN = gitea.hak8or.com PROTOCOL = http ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s HTTP_PORT = 3900 SSH_DOMAIN = gitea.hak8or.com STATIC_ROOT_PATH = /var/lib/gitea/ [database] DB_TYPE = sqlite3 PATH = /var/lib/gitea/data/gitea.db [security] INSTALL_LOCK = true SECRET_KEY = ---removed--- INTERNAL_TOKEN = ---removed--- [log] ROOT_PATH = /var/log/gitea/ LEVEL = Trace ``` ## Logs I do not see any log updates via ```journalctl -u gitea``` but sshd does see the attempt. ```bash [root@Gitea ~]# journalctl -u sshd --since "-1 minute" -f -- Logs begin at Wed 2018-05-30 19:53:01 UTC. -- Jun 01 02:33:27 Gitea sshd[14227]: Accepted publickey for gitea from 192.168.1.1 port 7183 ssh2: RSA SHA256:uNQY0bMlMR5K8OULv9HtQZwCou8NUd0ULoVIW6mjQiI Jun 01 02:33:27 Gitea sshd[14227]: pam_unix(sshd:session): session opened for user gitea by (uid=0) Jun 01 02:33:28 Gitea sshd[14227]: pam_unix(sshd:session): session closed for user gitea ````
GiteaMirror added the type/question label 2025-11-02 04:14:53 -06:00
Author
Owner

@lafriks commented on GitHub (Jun 1, 2018):

Seems to be configuration issue as dial tcp 127.0.0.1:3306 means that gitea tries to connect to MySQL and can not...

@lafriks commented on GitHub (Jun 1, 2018): Seems to be configuration issue as `dial tcp 127.0.0.1:3306` means that gitea tries to connect to MySQL and can not...
Author
Owner

@techknowlogick commented on GitHub (Jun 2, 2018):

Can you go into your admin dashboard and run Update the '.ssh/authorized_keys' file with Gitea SSH keys.. I have a suspicion that because you recently upgraded perhaps the old configuration may be linked somewhere.

@techknowlogick commented on GitHub (Jun 2, 2018): Can you go into your admin dashboard and run `Update the '.ssh/authorized_keys' file with Gitea SSH keys.`. I have a suspicion that because you recently upgraded perhaps the old configuration may be linked somewhere.
Author
Owner

@hak8or commented on GitHub (Jun 3, 2018):

@techknowlogick Tried that and sadly it doesn't seem to have an effect.

@lafriks I agree, that is what stumps me most and part of the reason for me filing this as a bug report. I have configured gitea to use sqlite3 and can verify this by going into the Admin panel and seeing the following for the database section:

Imgur

@hak8or commented on GitHub (Jun 3, 2018): @techknowlogick Tried that and sadly it doesn't seem to have an effect. @lafriks I agree, that is what stumps me most and part of the reason for me filing this as a bug report. I have configured gitea to use sqlite3 and can verify this by going into the Admin panel and seeing the following for the database section: ![Imgur](https://i.imgur.com/EV2ldH2.png)
Author
Owner

@lafriks commented on GitHub (Jun 4, 2018):

Check authorized_keys file contents to see if it point correct gitea binary and correct app.ini location

@lafriks commented on GitHub (Jun 4, 2018): Check authorized_keys file contents to see if it point correct gitea binary and correct app.ini location
Author
Owner

@techknowlogick commented on GitHub (Jun 4, 2018):

Also check .ssh/environment file (if exists) as it might set GITEA_CUSTOM environment variable

@techknowlogick commented on GitHub (Jun 4, 2018): Also check .ssh/environment file (if exists) as it might set `GITEA_CUSTOM` environment variable
Author
Owner

@hak8or commented on GitHub (Jul 21, 2018):

Apologies for not getting back to @lafriks and @techknowlogick for so long. Thank you for the suggestions.

I checked the authorized_keys file and it looked ok but I can't say with certainty. I did not see any .ssh/environment file. In the end I just deleted the authorized_keys file, re-imported my ssh key via gitea, and it all seems to work now. I am still not clear why it wasn't worked earlier, but I assume that an update went wrong and the command in authorized_keys got de-sync'd with what it should have been.

Closing since this issue has been resolved.

@hak8or commented on GitHub (Jul 21, 2018): Apologies for not getting back to @lafriks and @techknowlogick for so long. Thank you for the suggestions. I checked the ```authorized_keys``` file and it looked ok but I can't say with certainty. I did not see any ```.ssh/environment``` file. In the end I just deleted the ```authorized_keys``` file, re-imported my ssh key via gitea, and it all seems to work now. I am still not clear why it wasn't worked earlier, but I assume that an update went wrong and the command in authorized_keys got de-sync'd with what it should have been. Closing since this issue has been resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1843