[remote rejected] main -> main (pre-receive hook declined) #9718

Closed
opened 2025-11-02 08:47:29 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @Dynabits on GitHub (Oct 21, 2022).

Description

Git push always fails with error:

git push origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 209 bytes | 209.00 KiB/s, done.
Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
remote:
remote: Gitea: Internal Server Error
To http://192.168.1.99:3000/user/test.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'http://192.168.1.99:3000/user/test.git'

Gitea Version

Gitea version 1.17.3+4-g19df07f02 built with GNU Make 4.1, go1.18.7 : bindata, sqlite, sqlite_unlock_notify

Git Version

2.37.3

Operating System

Arch Linux

How are you running Gitea?

Binary download, fresh install, no containers.

Database

SQLite

Originally created by @Dynabits on GitHub (Oct 21, 2022). ### Description Git push always fails with error: ```bash git push origin main Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 209 bytes | 209.00 KiB/s, done. Total 3 (delta 0), reused 3 (delta 0), pack-reused 0 remote: remote: Gitea: Internal Server Error To http://192.168.1.99:3000/user/test.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'http://192.168.1.99:3000/user/test.git' ``` ### Gitea Version Gitea version 1.17.3+4-g19df07f02 built with GNU Make 4.1, go1.18.7 : bindata, sqlite, sqlite_unlock_notify ### Git Version 2.37.3 ### Operating System Arch Linux ### How are you running Gitea? Binary download, fresh install, no containers. ### Database SQLite
GiteaMirror added the issue/needs-feedback label 2025-11-02 08:47:29 -06:00
Author
Owner

@lunny commented on GitHub (Oct 21, 2022):

You can enable RUN_MODE as dev and try again to take a look at what's the error.

@lunny commented on GitHub (Oct 21, 2022): You can enable RUN_MODE as dev and try again to take a look at what's the error.
Author
Owner

@Dynabits commented on GitHub (Oct 21, 2022):

Output with RUN_MODE set to dev

git push origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 209 bytes | 209.00 KiB/s, done.
Total 3 (delta 0), reused 3 (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/user/test": dial tcp: lookup localhost on 1.1.1.1:53: no such host
To http://192.168.1.99:3000/user/test.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'http://192.168.1.99:3000/user/test.git'
@Dynabits commented on GitHub (Oct 21, 2022): Output with RUN_MODE set to dev ```bash git push origin main Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 209 bytes | 209.00 KiB/s, done. Total 3 (delta 0), reused 3 (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/user/test": dial tcp: lookup localhost on 1.1.1.1:53: no such host To http://192.168.1.99:3000/user/test.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'http://192.168.1.99:3000/user/test.git' ```
Author
Owner

@Dynabits commented on GitHub (Oct 21, 2022):

Ahh I see, looks like a post request is made with localost in the URL, that should be the IP address, not sure how to fix though.

@Dynabits commented on GitHub (Oct 21, 2022): Ahh I see, looks like a post request is made with localost in the URL, that should be the IP address, not sure how to fix though.
Author
Owner

@lunny commented on GitHub (Oct 21, 2022):

Because the host don't know what localhost means. Your /etc/hosts should be checked.

@lunny commented on GitHub (Oct 21, 2022): Because the host don't know what `localhost` means. Your /etc/hosts should be checked.
Author
Owner

@Dynabits commented on GitHub (Oct 21, 2022):

I added this line to /etc/hosts

127.0.0.1 localhost

Works like a charm now, thank you so much @lunny

@Dynabits commented on GitHub (Oct 21, 2022): I added this line to /etc/hosts ``` 127.0.0.1 localhost ``` Works like a charm now, thank you so much @lunny
Author
Owner

@codeex commented on GitHub (Oct 31, 2022):

on windows platform, it has the same error :Gitea: Internal Server Error
Unable to contact gitea: Post "http://localhost:3000/api/internal/hook/pre-receive/hhh/test": dial tcp: lookup localhost on 114.114.114.114:53: no such host.

I've modified C:\Windows\System32\drivers\etc\hosts, and added
127.0.0.1 localhost
but it has the same error, I don't know what I do again?

@codeex commented on GitHub (Oct 31, 2022): on windows platform, it has the same error :Gitea: Internal Server Error Unable to contact gitea: Post "http://localhost:3000/api/internal/hook/pre-receive/hhh/test": dial tcp: lookup localhost on 114.114.114.114:53: no such host. I've modified C:\Windows\System32\drivers\etc\hosts, and added 127.0.0.1 localhost but it has the same error, I don't know what I do again?
Author
Owner

@lunny commented on GitHub (Oct 31, 2022):

dial tcp: lookup localhost on 114.114.114.114:53: no such host.

It's a domain problem.

@lunny commented on GitHub (Oct 31, 2022): ``` dial tcp: lookup localhost on 114.114.114.114:53: no such host. ``` It's a domain problem.
Author
Owner

@jackzhum commented on GitHub (Nov 14, 2022):

dial tcp: lookup localhost on 114.114.114.114:53: no such host.

It's a domain problem.

I have the same problem. How can I solve it?

@jackzhum commented on GitHub (Nov 14, 2022): > ``` > dial tcp: lookup localhost on 114.114.114.114:53: no such host. > ``` > > It's a domain problem. I have the same problem. How can I solve it?
Author
Owner

@jackzhum commented on GitHub (Nov 14, 2022):

dial tcp: lookup localhost on 114.114.114.114:53: no such host.

It's a domain problem.

I have the same problem. How can I solve it?

I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency.

@jackzhum commented on GitHub (Nov 14, 2022): > > ``` > > dial tcp: lookup localhost on 114.114.114.114:53: no such host. > > ``` > > > > > > > > > > > > > > > > > > > > > > > > It's a domain problem. > > I have the same problem. How can I solve it? I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency.
Author
Owner

@jinyangcruise commented on GitHub (Jan 8, 2023):

@jackzhum

dial tcp: lookup localhost on 114.114.114.114:53: no such host.

It's a domain problem.

I have the same problem. How can I solve it?

I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency.

I have the same problem. what is "LOCAL_ ROOT_ "? I can not find a LOCAL_ in my app.ini.
here is my my app.ini content:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = Administrator
RUN_MODE = dev

[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = gitea
PASSWD   = 
SCHEMA   = 
SSL_MODE = disable
CHARSET  = utf8
PATH     = D:\Program Files\Gitea\data\gitea.db
LOG_SQL  = false

[repository]
ROOT = D:/Program Files/Gitea/data/gitea-repositories

[server]
SSH_DOMAIN       = localhost
DOMAIN           = localhost
HTTP_PORT        = 3000
ROOT_URL         = http://localhost:3000/
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_START_SERVER = true
LFS_JWT_SECRET   = clQ9TFYBIEYvXxNMoS8wQGZtKSHEGQiyK-92TeM7pjM
OFFLINE_MODE     = false

[lfs]
PATH = D:/Program Files/Gitea/data/lfs

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = false
DISABLE_REGISTRATION              = false
ALLOW_ONLY_EXTERNAL_REGISTRATION  = false
ENABLE_CAPTCHA                    = false
REQUIRE_SIGNIN_VIEW               = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.localhost

[picture]
ENABLE_FEDERATED_AVATAR = false

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

[session]
PROVIDER = file

[log]
MODE      = console
LEVEL     = info
ROOT_PATH = D:/Program Files/Gitea/log
ROUTER    = console

[repository.pull-request]
DEFAULT_MERGE_STYLE = merge

[repository.signing]
DEFAULT_TRUST_MODEL = committer

[security]
INSTALL_LOCK       = true
INTERNAL_TOKEN     = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NzMxNjUzMDB9.v6dxMxoc0adzKb6CDhHKErdRRTmCePx-Wc6epXht3is
PASSWORD_HASH_ALGO = pbkdf2
@jinyangcruise commented on GitHub (Jan 8, 2023): @jackzhum > > > ``` > > > dial tcp: lookup localhost on 114.114.114.114:53: no such host. > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It's a domain problem. > > > > > > I have the same problem. How can I solve it? > > I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency. I have the same problem. what is "LOCAL_ ROOT_ "? I can not find a LOCAL_ in my app.ini. here is my my app.ini content: ``` APP_NAME = Gitea: Git with a cup of tea RUN_USER = Administrator RUN_MODE = dev [database] DB_TYPE = sqlite3 HOST = 127.0.0.1:3306 NAME = gitea USER = gitea PASSWD = SCHEMA = SSL_MODE = disable CHARSET = utf8 PATH = D:\Program Files\Gitea\data\gitea.db LOG_SQL = false [repository] ROOT = D:/Program Files/Gitea/data/gitea-repositories [server] SSH_DOMAIN = localhost DOMAIN = localhost HTTP_PORT = 3000 ROOT_URL = http://localhost:3000/ DISABLE_SSH = false SSH_PORT = 22 LFS_START_SERVER = true LFS_JWT_SECRET = clQ9TFYBIEYvXxNMoS8wQGZtKSHEGQiyK-92TeM7pjM OFFLINE_MODE = false [lfs] PATH = D:/Program Files/Gitea/data/lfs [mailer] ENABLED = false [service] REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = false DISABLE_REGISTRATION = false ALLOW_ONLY_EXTERNAL_REGISTRATION = false ENABLE_CAPTCHA = false REQUIRE_SIGNIN_VIEW = false DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_ALLOW_CREATE_ORGANIZATION = true DEFAULT_ENABLE_TIMETRACKING = true NO_REPLY_ADDRESS = noreply.localhost [picture] ENABLE_FEDERATED_AVATAR = false [openid] ENABLE_OPENID_SIGNIN = true ENABLE_OPENID_SIGNUP = true [session] PROVIDER = file [log] MODE = console LEVEL = info ROOT_PATH = D:/Program Files/Gitea/log ROUTER = console [repository.pull-request] DEFAULT_MERGE_STYLE = merge [repository.signing] DEFAULT_TRUST_MODEL = committer [security] INSTALL_LOCK = true INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NzMxNjUzMDB9.v6dxMxoc0adzKb6CDhHKErdRRTmCePx-Wc6epXht3is PASSWORD_HASH_ALGO = pbkdf2 ```
Author
Owner

@jackzhum commented on GitHub (Jan 16, 2023):

@jackzhum

dial tcp: lookup localhost on 114.114.114.114:53: no such host.

It's a domain problem.

I have the same problem. How can I solve it?

I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency.

I have the same problem. what is "LOCAL_ ROOT_ "? I can not find a LOCAL_ in my app.ini. here is my my app.ini content:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = Administrator
RUN_MODE = dev

[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = gitea
PASSWD   = 
SCHEMA   = 
SSL_MODE = disable
CHARSET  = utf8
PATH     = D:\Program Files\Gitea\data\gitea.db
LOG_SQL  = false

[repository]
ROOT = D:/Program Files/Gitea/data/gitea-repositories

[server]
SSH_DOMAIN       = localhost
DOMAIN           = localhost
HTTP_PORT        = 3000
ROOT_URL         = http://localhost:3000/
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_START_SERVER = true
LFS_JWT_SECRET   = clQ9TFYBIEYvXxNMoS8wQGZtKSHEGQiyK-92TeM7pjM
OFFLINE_MODE     = false

[lfs]
PATH = D:/Program Files/Gitea/data/lfs

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = false
DISABLE_REGISTRATION              = false
ALLOW_ONLY_EXTERNAL_REGISTRATION  = false
ENABLE_CAPTCHA                    = false
REQUIRE_SIGNIN_VIEW               = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.localhost

[picture]
ENABLE_FEDERATED_AVATAR = false

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

[session]
PROVIDER = file

[log]
MODE      = console
LEVEL     = info
ROOT_PATH = D:/Program Files/Gitea/log
ROUTER    = console

[repository.pull-request]
DEFAULT_MERGE_STYLE = merge

[repository.signing]
DEFAULT_TRUST_MODEL = committer

[security]
INSTALL_LOCK       = true
INTERNAL_TOKEN     = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NzMxNjUzMDB9.v6dxMxoc0adzKb6CDhHKErdRRTmCePx-Wc6epXht3is
PASSWORD_HASH_ALGO = pbkdf2

https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini
image

@jackzhum commented on GitHub (Jan 16, 2023): > @jackzhum > > > > > ``` > > > > dial tcp: lookup localhost on 114.114.114.114:53: no such host. > > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It's a domain problem. > > > > > > > > > I have the same problem. How can I solve it? > > > > > > I solved this problem: I will LOCAL_ ROOT_ The URL is changed to be the same as ROOT_ URL consistency. > > I have the same problem. what is "LOCAL_ ROOT_ "? I can not find a LOCAL_ in my app.ini. here is my my app.ini content: > > ``` > APP_NAME = Gitea: Git with a cup of tea > RUN_USER = Administrator > RUN_MODE = dev > > [database] > DB_TYPE = sqlite3 > HOST = 127.0.0.1:3306 > NAME = gitea > USER = gitea > PASSWD = > SCHEMA = > SSL_MODE = disable > CHARSET = utf8 > PATH = D:\Program Files\Gitea\data\gitea.db > LOG_SQL = false > > [repository] > ROOT = D:/Program Files/Gitea/data/gitea-repositories > > [server] > SSH_DOMAIN = localhost > DOMAIN = localhost > HTTP_PORT = 3000 > ROOT_URL = http://localhost:3000/ > DISABLE_SSH = false > SSH_PORT = 22 > LFS_START_SERVER = true > LFS_JWT_SECRET = clQ9TFYBIEYvXxNMoS8wQGZtKSHEGQiyK-92TeM7pjM > OFFLINE_MODE = false > > [lfs] > PATH = D:/Program Files/Gitea/data/lfs > > [mailer] > ENABLED = false > > [service] > REGISTER_EMAIL_CONFIRM = false > ENABLE_NOTIFY_MAIL = false > DISABLE_REGISTRATION = false > ALLOW_ONLY_EXTERNAL_REGISTRATION = false > ENABLE_CAPTCHA = false > REQUIRE_SIGNIN_VIEW = false > DEFAULT_KEEP_EMAIL_PRIVATE = false > DEFAULT_ALLOW_CREATE_ORGANIZATION = true > DEFAULT_ENABLE_TIMETRACKING = true > NO_REPLY_ADDRESS = noreply.localhost > > [picture] > ENABLE_FEDERATED_AVATAR = false > > [openid] > ENABLE_OPENID_SIGNIN = true > ENABLE_OPENID_SIGNUP = true > > [session] > PROVIDER = file > > [log] > MODE = console > LEVEL = info > ROOT_PATH = D:/Program Files/Gitea/log > ROUTER = console > > [repository.pull-request] > DEFAULT_MERGE_STYLE = merge > > [repository.signing] > DEFAULT_TRUST_MODEL = committer > > [security] > INSTALL_LOCK = true > INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NzMxNjUzMDB9.v6dxMxoc0adzKb6CDhHKErdRRTmCePx-Wc6epXht3is > PASSWORD_HASH_ALGO = pbkdf2 > ``` https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini ![image](https://user-images.githubusercontent.com/15189709/212605043-ea58855a-5da3-4e0e-abc1-91329a7bfca7.png)
Author
Owner

@zeripath commented on GitHub (Jan 16, 2023):

THOSE EXPERIENCING THIS ON WINDOWS IN 1.18 - YOU ARE EXPERIENCING A DUPLICATE OF #22370

Please see https://github.com/go-gitea/gitea/issues/22370#issuecomment-1384083726

DESCRIPTION

This bug is due to a change in Go's handling of the netgo build 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 netgo for all platforms. (see https://github.com/go-gitea/gitea/issues/22370#issuecomment-1383936251)

#22467 and #22468 should fix this for 1.18.1 and 1.19-dev.

WORKAROUND

For 1.18.0 set the GODEBUG=netdns=cgo environment variable when running gitea and/or update your LOCAL_ROOT_URL to use an IP address

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

@zeripath commented on GitHub (Jan 16, 2023): ## THOSE EXPERIENCING THIS ON WINDOWS IN 1.18 - YOU ARE EXPERIENCING A DUPLICATE OF #22370 Please see https://github.com/go-gitea/gitea/issues/22370#issuecomment-1384083726 ## DESCRIPTION This bug is due to a change in Go's handling of the `netgo` build 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 `netgo` for all platforms. (see https://github.com/go-gitea/gitea/issues/22370#issuecomment-1383936251) #22467 and #22468 should fix this for 1.18.1 and 1.19-dev. ## WORKAROUND For 1.18.0 set the `GODEBUG=netdns=cgo` environment variable when running gitea and/or update your LOCAL_ROOT_URL to use an IP address 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
Author
Owner

@gilbertoca commented on GitHub (Jan 27, 2023):

In our case, bringing our server from gitea-1.16.9-linux-amd64 to gitea-1.17.4-linux-amd64, we needed to remove that parameter:

#LOCAL_ROOT_URL = https://localhost:3000/

Maybe is not just a windows problem? @zeripath

@gilbertoca commented on GitHub (Jan 27, 2023): In our case, bringing our server from **gitea-1.16.9-linux-amd64** to **gitea-1.17.4-linux-amd64**, we needed to remove that parameter: `#LOCAL_ROOT_URL = https://localhost:3000/` Maybe is not just a windows problem? @zeripath
Author
Owner

@zeripath commented on GitHub (Jan 27, 2023):

@gilbertoca on 1.18 this bug was one of a cluster of issues opened due to a change in the way Golang handles the build tag netgo in Golang 1.18. This broke IP lookup of localhost.

Whatever issue you were experiencing is different and if you're still experiencing you should consider opening a separate bug report with complete information about what your experience is. However, 1.17 is now out of support so you would need to show that your problem existed on 1.18 too. On 1.17 as was originally experienced this was due to missing alias for 127.0.0.1 in /etc/hosts.

The other thing to note - is that your problem was solved by doing the opposite to how this bug was worked around for others. That your solution requires the opposite says that the problem is likely a different thing.

In any case I'm going to lock this conversation - this bug is resolved and was a duplicate of #22730

@zeripath commented on GitHub (Jan 27, 2023): @gilbertoca on 1.18 this bug was one of a cluster of issues opened due to a change in the way Golang handles the build tag `netgo` in Golang 1.18. This broke IP lookup of localhost. Whatever issue you were experiencing is different and if you're still experiencing you should consider opening a separate bug report with complete information about what your experience is. However, 1.17 is now out of support so you would need to show that your problem existed on 1.18 too. On 1.17 as was originally experienced this was due to missing alias for 127.0.0.1 in /etc/hosts. The other thing to note - is that your problem was solved by doing the opposite to how this bug was worked around for others. That your solution requires the opposite says that the problem is likely a different thing. In any case I'm going to lock this conversation - this bug is resolved and was a duplicate of #22730
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9718