mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-13 11:31:28 -05:00
1.18.0 on Windows error: can not resolve localhost, ! [remote rejected] master -> master (pre-receive hook declined) #10070
Closed
opened 2025-11-02 08:57:22 -06:00 by GiteaMirror
·
28 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16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-rc3
v1.4.0-rc2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#10070
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jinyangcruise on GitHub (Jan 8, 2023).
Description
Save your time:
Detailed:
I use 1.18.0 Gitea, when I push files, occur:
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
@lunny commented on GitHub (Jan 8, 2023):
Could you
ping localhost?@wxiaoguang commented on GitHub (Jan 8, 2023):
Workaround: set LOCAL_ROOT_URL with 127.0.0.1, do not use localhost
@jinyangcruise commented on GitHub (Jan 9, 2023):
yes
@jinyangcruise commented on GitHub (Jan 9, 2023):
I can't find a LOCAL_ROOT_URL in app.ini, should I add it at somewhere?
@lunny commented on GitHub (Jan 9, 2023):
Please check the documentation.
@jinyangcruise commented on GitHub (Jan 9, 2023):
Thank you very much! Success!
By the way, english version documentation has this LOCAL_ROOT_URL but chinese version not.
https://docs.gitea.io/en-us/config-cheat-sheet/#server-server
https://docs.gitea.io/zh-cn/config-cheat-sheet/#server-server
@emehmet commented on GitHub (Jan 10, 2023):
it does not work for me
@starpeng commented on GitHub (Jan 10, 2023):
it work for me
@jinyangcruise commented on GitHub (Jan 10, 2023):
workaround:
LOCAL_ROOT_URL = http://127.0.0.1:3000/
@lunny commented on GitHub (Jan 10, 2023):
Is your problem the same as others?
@zeripath commented on GitHub (Jan 10, 2023):
So leaving aside the workaround which I am sure will fix the issues people are describing - I don't understand why it is needed or what has changed to make it needed.
As far as I can see the determination of the value of
setting.LocalURL(i.e. that whichLOCAL_ROOT_URLmaps to) has not changed and nor has the dialer for this code.So I don't understand why this should suddenly be a problem...
@zeripath commented on GitHub (Jan 10, 2023):
For others seeing this conversation the
LOCAL_ROOT_URLis in the[server]section of the app.ini and it must be added there.@emehmet commented on GitHub (Jan 10, 2023):
Hey @jinyangcruise
It worked as you said.
Thank you! 👍
@wxiaoguang commented on GitHub (Jan 11, 2023):
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.@zeripath commented on GitHub (Jan 11, 2023):
We could use 127.0.0.1 instead of localhost only on windows then we get none of the cons.
@zeripath commented on GitHub (Jan 11, 2023):
But yes I agree I think this was closed too soon and we need to add a patch - if not for the users, then just to save ourselves time.
@DuaneDu commented on GitHub (Jan 11, 2023):
@zeripath
Config is
error

console log

gitea.log
gitea.log
@KazzmanK commented on GitHub (Jan 11, 2023):
Same problem for me, windows install, for unknown reason problem raised today, yesterday it was ok.
in hosts we have 127.0.0.1 localhost record. It still calls for dns and fails.
workaround with LOCAL_ROOT_URL helped.
@DuaneDu , add DEV run mode, client will show bit more detailed error message
@zeripath commented on GitHub (Jan 11, 2023):
@DuaneDu your logs now indicate that things are should now be working correctly for you.
Your pre-receive hook is being declined by the user does not have permission to that repo
@wxiaoguang commented on GitHub (Jan 11, 2023):
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.@natsutteatsuiyone commented on GitHub (Jan 11, 2023):
This webhook error may be related to this issue.
https://gist.github.com/natsutteatsuiyone/4c7b8e3b444a61080bb04ece20b316aa
@DuaneDu commented on GitHub (Jan 12, 2023):
@zeripath
RUN_MODE=dev
gitea.log
router.log
RUN_MODE=test
gitea.log
router.log
@zeripath commented on GitHub (Jan 16, 2023):
It certainly appears that the upstream DNS server it is discovering is doing the incorrect thing for at least localhost...
I guess the question is what does the netgo tag do on Windows build and is it really necessary to make a "static" build with it for windows? Removing netgo here:
16e9dec827/Makefile (L759-L764)would create "Static" builds for windows without the use of netgo.
@zeripath commented on GitHub (Jan 16, 2023):
I guess an option is to ask users who are affected if they can run Gitea with the environment variable
GODEBUG=netdns=cgo, e.g.:That should force the use of the win32 api.
@wxiaoguang commented on GitHub (Jan 16, 2023):
I have reported the bug to Go team (it has been confirmed as NeedsFix there)
I guess the
netgoin Makefile was just a Copy&Paste and it's not necessary.And, the
netgoseemed to be a no-op on Windows before. But Go 1.19 rewrite the code for it.So, IMO it's good to remove the
netgotag for Windows build at the moment. When Go team fix the bug, re-enable thenetgotag then (if it's really needed ...)@zeripath commented on GitHub (Jan 16, 2023):
Agreed I've just looked up the source code for golang and I've come to the same conclusion. netgo only affects lookup on windows and previously was a no-op. Therefore we can and should safely remove until/unless go can make it work correctly.
Are you able to send a PR @wxiaoguang ?
@zeripath commented on GitHub (Jan 16, 2023):
As an aside I suspect the problem is here:
d52883f443/src/net/conf.go (L134-L145)That code cannot check the /etc/hosts file and thus I bet the dns lookup is going out to an external server and we're getting the external name for the host.
@zeripath commented on GitHub (Jan 16, 2023):
DESCRIPTION
This bug is due to a change in Go's handling of the
netgobuild tag for Windows see:https://github.com/go-gitea/gitea/issues/22370#issuecomment-1378669025
We were bitten by this because we build our static precompiled binaries with
netgofor all platforms. (see https://github.com/go-gitea/gitea/issues/22370#issuecomment-1383936251)#22467 and #22468 should fix this for 1.18-dev, 1.18.1 and 1.19-dev.
WORKAROUND
For 1.18.0 set the
GODEBUG=netdns=cgoenvironment variable when running gitea.https://github.com/go-gitea/gitea/issues/22370#issuecomment-1383944400
Builds of what will become 1.18.1 are available now on https://dl.gitea.io/gitea/1.18