Can't push to localhost without internet connection #11517

Closed
opened 2025-11-02 09:39:55 -06:00 by GiteaMirror · 16 comments
Owner

Originally created by @IamRezaMousavi on GitHub (Aug 23, 2023).

Description

When I pushed to localhost without an internet connection, I got this error:

remote: 
remote: Gitea: Internal Server Connection Error
To http://localhost:3000/iamrezamousavi/my-env.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'http://localhost:3000/iamrezamousavi/my-env.git'

But if I connect to the Internet, it works fine
This is very annoying (to work locally)

Gitea Version

Gitea version 1.20.2 built with GNU Make 4.1, go1.20.6 : bindata, sqlite, sqlite_unlock_notify

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

git version 2.41.0

Operating System

Arch Linux

How are you running Gitea?

I use binary files

Database

SQLite

Originally created by @IamRezaMousavi on GitHub (Aug 23, 2023). ### Description When I pushed to localhost without an internet connection, I got this error: ``` remote: remote: Gitea: Internal Server Connection Error To http://localhost:3000/iamrezamousavi/my-env.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'http://localhost:3000/iamrezamousavi/my-env.git' ``` But if I connect to the Internet, it works fine This is very annoying (to work locally) ### Gitea Version Gitea version 1.20.2 built with GNU Make 4.1, go1.20.6 : bindata, sqlite, sqlite_unlock_notify ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version git version 2.41.0 ### Operating System Arch Linux ### How are you running Gitea? I use binary files ### Database SQLite
GiteaMirror added the issue/needs-feedback label 2025-11-02 09:39:55 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

Check your LOCAL_ROOT_URL (Maybe it should be http://127.0.0.1:3000)

@wxiaoguang commented on GitHub (Aug 23, 2023): Check your LOCAL_ROOT_URL (Maybe it should be `http://127.0.0.1:3000`)
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

Check your LOCAL_ROOT_URL (Maybe it should be http://127.0.0.1:3000)

I have this in app.ini file:

[server]
SSH_DOMAIN = localhost
DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://localhost:3000/
@IamRezaMousavi commented on GitHub (Aug 23, 2023): > Check your LOCAL_ROOT_URL (Maybe it should be `http://127.0.0.1:3000`) I have this in `app.ini` file: ```ini [server] SSH_DOMAIN = localhost DOMAIN = localhost HTTP_PORT = 3000 ROOT_URL = http://localhost:3000/ ```
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

What's the full config? Does curl http://localhost:3000/ work when there is no internet connection?

@wxiaoguang commented on GitHub (Aug 23, 2023): What's the full config? Does `curl http://localhost:3000/` work when there is no internet connection?
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

What's the full config? Does curl http://localhost:3000/ work when there is no internet connection?

Yes, curl return a html page.

Gitea was working before, but when I updated it, it became like this.

And this is full config:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = reza
RUN_MODE = prod
# WORK_PATH = D:\srv\gitea
WORK_PATH = /run/media/reza/68F40575F40546B2/srv/gitea

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

[repository]
ROOT = ./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 = ...
OFFLINE_MODE = false

[lfs]
PATH = ./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]
DISABLE_GRAVATAR = true
ENABLE_FEDERATED_AVATAR = false

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

[session]
PROVIDER = file

[log]
MODE = console
LEVEL = info
ROOT_PATH = ./log
ROUTER = console

[repository.pull-request]
DEFAULT_MERGE_STYLE = merge

[repository.signing]
DEFAULT_TRUST_MODEL = committer

[security]
INSTALL_LOCK = true
INTERNAL_TOKEN = ...
PASSWORD_HASH_ALGO = ...

[attachment]
ENABLE = true
PATH = ./data/attachments
MAX_SIZE = 1024
MAX_FILE = 100

[oauth2]
JWT_SECRET = ...
@IamRezaMousavi commented on GitHub (Aug 23, 2023): > What's the full config? Does `curl http://localhost:3000/` work when there is no internet connection? Yes, curl return a html page. Gitea was working before, but when I updated it, it became like this. And this is full config: ```ini APP_NAME = Gitea: Git with a cup of tea RUN_USER = reza RUN_MODE = prod # WORK_PATH = D:\srv\gitea WORK_PATH = /run/media/reza/68F40575F40546B2/srv/gitea [database] DB_TYPE = sqlite3 HOST = 127.0.0.1:3306 NAME = gitea USER = gitea PASSWD = SCHEMA = SSL_MODE = disable CHARSET = utf8 PATH = ./data/gitea.db LOG_SQL = false [repository] ROOT = ./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 = ... OFFLINE_MODE = false [lfs] PATH = ./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] DISABLE_GRAVATAR = true ENABLE_FEDERATED_AVATAR = false [openid] ENABLE_OPENID_SIGNIN = true ENABLE_OPENID_SIGNUP = true [session] PROVIDER = file [log] MODE = console LEVEL = info ROOT_PATH = ./log ROUTER = console [repository.pull-request] DEFAULT_MERGE_STYLE = merge [repository.signing] DEFAULT_TRUST_MODEL = committer [security] INSTALL_LOCK = true INTERNAL_TOKEN = ... PASSWORD_HASH_ALGO = ... [attachment] ENABLE = true PATH = ./data/attachments MAX_SIZE = 1024 MAX_FILE = 100 [oauth2] JWT_SECRET = ... ```
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

That's really strange. Internal Server Connection Error means the gitea ssh command can't communicate with LOCAL_ROOT_URL

Could you try to add LOCAL_ROOT_URL = http://127.0.0.1:3000 besides the ROOT_URL ?

@wxiaoguang commented on GitHub (Aug 23, 2023): That's really strange. `Internal Server Connection Error` means the gitea ssh command can't communicate with `LOCAL_ROOT_URL` Could you try to add `LOCAL_ROOT_URL = http://127.0.0.1:3000` besides the `ROOT_URL` ?
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

Could you try to add LOCAL_ROOT_URL = http://127.0.0.1:3000 besides the ROOT_URL ?

LOCAL_ROOT_URL = http://127.0.0.1:3000/ is works.
But LOCAL_ROOT_URL = http://localhost:3000/ doesn't work

Is this a bug?

@IamRezaMousavi commented on GitHub (Aug 23, 2023): > Could you try to add `LOCAL_ROOT_URL = http://127.0.0.1:3000` besides the `ROOT_URL` ? `LOCAL_ROOT_URL = http://127.0.0.1:3000/` is works. But `LOCAL_ROOT_URL = http://localhost:3000/` doesn't work Is this a bug?
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection.

But I don't have the environment to reproduce, if you could reproduce, feel free to report it to upstream.

  1. Do you have "localhost" entry in your "hosts" file?
  2. Does OS/Golang resolve it (localhost) correctly? eg: https://github.com/golang/go/issues/57757
@wxiaoguang commented on GitHub (Aug 23, 2023): I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection. But I don't have the environment to reproduce, if you could reproduce, feel free to report it to upstream. 1. Do you have "localhost" entry in your "hosts" file? 2. Does OS/Golang resolve it (localhost) correctly? eg: `https://github.com/golang/go/issues/57757`
Author
Owner

@lunny commented on GitHub (Aug 23, 2023):

Could you change RUN_MODE=dev in your app.ini, restart gitea and try again? Then if there is an error, it will be displayed.

@lunny commented on GitHub (Aug 23, 2023): Could you change `RUN_MODE=dev` in your app.ini, restart gitea and try again? Then if there is an error, it will be displayed.
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

Could you change RUN_MODE=dev in your app.ini, restart gitea and try again? Then if there is an error, it will be displayed.

remote: 
remote: Gitea: Internal Server Connection Error
remote: Gitea: HookPreReceive(last) failed: unable to contact gitea "POST http://localhost:3000/api/internal/hook/pre-receive/iamrezamousavi/test1": Post "http://localhost:3000/api/internal/hook/pre-receive/iamrezamousavi/test1": dial tcp: lookup localhost on [::1]:53: read udp [::1]:40887->[::1]:53: read: connection refused
To http://localhost:3000/iamrezamousavi/test1.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://localhost:3000/iamrezamousavi/test1.git'
@IamRezaMousavi commented on GitHub (Aug 23, 2023): > Could you change `RUN_MODE=dev` in your app.ini, restart gitea and try again? Then if there is an error, it will be displayed. ```sh remote: remote: Gitea: Internal Server Connection Error remote: Gitea: HookPreReceive(last) failed: unable to contact gitea "POST http://localhost:3000/api/internal/hook/pre-receive/iamrezamousavi/test1": Post "http://localhost:3000/api/internal/hook/pre-receive/iamrezamousavi/test1": dial tcp: lookup localhost on [::1]:53: read udp [::1]:40887->[::1]:53: read: connection refused To http://localhost:3000/iamrezamousavi/test1.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'http://localhost:3000/iamrezamousavi/test1.git' ```
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection.

Gitea works well for me locally, (I mean sign in, create repo, add files, delete repo and ...)
but I can't push anything locally to it

@IamRezaMousavi commented on GitHub (Aug 23, 2023): > I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection. Gitea works well for me locally, (I mean sign in, create repo, add files, delete repo and ...) but I can't push anything locally to it
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection.

Gitea works well for me locally, (I mean sign in, create repo, add files, delete repo and ...) but I can't push anything locally to it

I think I have explained above:

Internal Server Connection Error means the gitea ssh command can't communicate with LOCAL_ROOT_URL

I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection.

@wxiaoguang commented on GitHub (Aug 23, 2023): > > I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection. > > Gitea works well for me locally, (I mean sign in, create repo, add files, delete repo and ...) but I can't push anything locally to it I think I have explained above: > `Internal Server Connection Error` means the gitea ssh command can't communicate with `LOCAL_ROOT_URL` > I think it's OS's or Golang's bug: it doesn't resolve "localhost" when there is no internet connection.
Author
Owner

@lunny commented on GitHub (Aug 23, 2023):

@wxiaoguang is right it's a dns problem. maybe you need to add localhost to your hosts file

@lunny commented on GitHub (Aug 23, 2023): @wxiaoguang is right it's a dns problem. maybe you need to add localhost to your hosts file
Author
Owner

@KazzmanK commented on GitHub (Aug 23, 2023):

@IamRezaMousavi ,
this is a known issue, https://github.com/go-gitea/gitea/issues/22370

And: https://tip.golang.org/doc/go1.19#net

The net package now has initial support for the netgo build tag on Windows. When used, the package uses the Go DNS client (as used by Resolver.PreferGo) instead of asking Windows for DNS results. The upstream DNS server it discovers from Windows may not yet be correct with complex system network configurations, however.

Removing the netgo tag from Windows build may resolve the problem.
@KazzmanK commented on GitHub (Aug 23, 2023): @IamRezaMousavi , this is a known issue, https://github.com/go-gitea/gitea/issues/22370 ``` And: https://tip.golang.org/doc/go1.19#net The net package now has initial support for the netgo build tag on Windows. When used, the package uses the Go DNS client (as used by Resolver.PreferGo) instead of asking Windows for DNS results. The upstream DNS server it discovers from Windows may not yet be correct with complex system network configurations, however. Removing the netgo tag from Windows build may resolve the problem. ```
Author
Owner

@IamRezaMousavi commented on GitHub (Aug 23, 2023):

@IamRezaMousavi , this is a known issue, #22370

And: https://tip.golang.org/doc/go1.19#net

The net package now has initial support for the netgo build tag on Windows. When used, the package uses the Go DNS client (as used by Resolver.PreferGo) instead of asking Windows for DNS results. The upstream DNS server it discovers from Windows may not yet be correct with complex system network configurations, however.

Removing the netgo tag from Windows build may resolve the problem.

I use Arch linux
And this bug still unsolved :)

@IamRezaMousavi commented on GitHub (Aug 23, 2023): > @IamRezaMousavi , this is a known issue, #22370 > > ``` > And: https://tip.golang.org/doc/go1.19#net > > The net package now has initial support for the netgo build tag on Windows. When used, the package uses the Go DNS client (as used by Resolver.PreferGo) instead of asking Windows for DNS results. The upstream DNS server it discovers from Windows may not yet be correct with complex system network configurations, however. > > Removing the netgo tag from Windows build may resolve the problem. > ``` I use `Arch linux` And this bug still unsolved :)
Author
Owner

@wxiaoguang commented on GitHub (Aug 23, 2023):

I use Arch linux
And this bug still unsolved :)

There were some possible steps to move forward:

  1. Do you have "localhost" entry in your "hosts" file?
  2. Does OS/Golang resolve it (localhost) correctly? eg: https://github.com/golang/go/issues/57757
@wxiaoguang commented on GitHub (Aug 23, 2023): > I use `Arch linux` > And this bug still unsolved :) There were some possible steps to move forward: > 1. Do you have "localhost" entry in your "hosts" file? > 2. Does OS/Golang resolve it (localhost) correctly? eg: `https://github.com/golang/go/issues/57757`
Author
Owner

@wxiaoguang commented on GitHub (Aug 27, 2023):

Since there is no more feedback, I think this issue could be closed.

The root cause is that the Golang doesn't resolve "localhost" when there is no internet connection. It could be caused by misconfiguration of the OS (eg: /etc/hosts, resolver, etc) or Golang's problem which doesn't respect /etc/hosts.

Feel free to reopen with more clues (and reproducible steps/examples)

@wxiaoguang commented on GitHub (Aug 27, 2023): Since there is no more feedback, I think this issue could be closed. The root cause is that the Golang doesn't resolve "localhost" when there is no internet connection. It could be caused by misconfiguration of the OS (eg: /etc/hosts, resolver, etc) or Golang's problem which doesn't respect /etc/hosts. Feel free to reopen with more clues (and reproducible steps/examples)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11517