gitea: 1.18.0 on Windows error: can not resolve localhost, ! [remote rejected] master -> master (pre-receive hook declined)
Description
Save your time:
1.17.4 is good but 1.18.0 has a bug:
dial tcp: lookup localhost on 114.114.114.114:53: no such host
Detailed:
I use 1.18.0 Gitea, when I push files, occur:
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 20 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 305 bytes | 305.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Gitea: Internal Server Error
remote: Unable to contact gitea: Post "http://localhost:3000/api/internal/hook/pre-receive/jinyang/test": dial tcp: lookup localhost on 114.114.114.114:53: no such host
To http://localhost:3000/jinyang/test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://localhost:3000/jinyang/test.git'
I searched some related issues but finally failed to fix this.
Then I installed 1.17.4 Gitea and this problem gone.
Then I re-installed 1.18.0 Gitea again and still can not push.
Gitea Version
1.18.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
NA
Git Version
git version 2.39.0.windows.2
Operating System
WINDOWS 11
How are you running Gitea?
download binary on https://dl.gitea.io/gitea [gitea-1.18.0-windows-4.0-amd64.exe]
download it on my PC and move it to D:\Program Files\Gitea, then double click the gitea-1.18.0-windows-4.0-amd64.exe
Database
SQLite
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 28 (18 by maintainers)
Commits related to this issue
- Remove the netgo tag for Windows build (#22467) (#22468) Backport #22467 Fix #22370 and more. Before Go 1.19, the `netgo` tag for Windows does nothing. But Go 1.19 rewrite the net package c... — committed to go-gitea/gitea by wxiaoguang a year ago
- Remove the netgo tag for Windows build (#22467) Fix #22370 and more. Before Go 1.19, the `netgo` tag for Windows does nothing. But Go 1.19 rewrite the net package code for Windows DNS, and ther... — committed to go-gitea/gitea by wxiaoguang a year ago
I think this issue should be re-opened and it needs a patch.
To make the workaround prominent, I didn’t say too much about my guess before.
Here is my opinion of this bug:
How it happens?
Gitea (Golang net package) can not resolve host
localhost.Golang’s net package need correct
/etc/hostsand/etc/nsswitch.confto resolve domains correctly. If anything is broken, it may not resolve some domains. On Windows, it also depends onC:\Windows\System32\Drivers\etc\hostsfileWhy there are so many reports recently?
Possibility 1
Alpine / Go or Go for Windows changed some behaviors which conflict with user’s environment, then Golang’s net package doens’t work well in some rare cases (no evidence yet). But since some users reported that 1.17.x works but 1.18.x fails, maybe there is something changed.
Possibility 2
Many users’ systems were already broken, they messed up their
hostsfile, they might have deleted the127.0.0.1 localhostline. I know a lot of such users.Before, some public DNS servers can also resolve
localhost, for example, there is still one now:Recently some public DNS servers might have stopped such non-standard behavior, if they do not resolve localhost anymore, the users with broken localhost definition will encounter the problem.
So, some users with broken
hostsfiles can get Gitea working before, but get errors now.The patch
Approach 1
Use
127.0.0.1instead oflocalhostfor the default value of LOCAL_ROOT_URLPros
hostsfile is broken, it still worksCons
Approach 2
Find the root case why 1.17.x works but 1.18.x doesn’t.
Update: maybe it’s a Go 1.19 bug: https://github.com/golang/go/issues/53490
And: https://tip.golang.org/doc/go1.19#net
Removing the
netgotag from Windows build may resolve the problem.Approach 3
Try to resolve
localhostat startup, report fatal errors if the resolution fails.I think it’s related to this Go bug:
And: https://tip.golang.org/doc/go1.19#net
Removing the
netgotag from Windows build may resolve the problem.For others seeing this conversation the
LOCAL_ROOT_URLis in the[server]section of the app.ini and it must be added there.