Getting Internal server Error 500: when accessing, pushing, pulling repositories when running gitea as a Windows service #8920

Open
opened 2025-11-02 08:23:09 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @Avinashachu007 on GitHub (May 6, 2022).

Description

I'm running a Gitea on-Premise for several years. Recently, When I access certain repositories, I get Internal server Error (500) in the Web UI. For those repo, I can't able to push or pull commit. More and More repositories are started giving the Error.

I Noticed that Internal server error occurs, when I running gitea as Windows service. Below is the error from debug log.. Strangely When I run the Gitea.exe by Right click -> Run as Administrator, No errors.

2022/05/06 12:59:44 ...s/context/context.go:204:HTML() [D] Template: status/500
2022/05/06 12:59:57 ...dules/git/command.go:146:RunWithContext() [D] E:\APPS\Installations\gitea\data\git\repo\mbc\mbc_adminportal.git: C:\Program Files\Git\cmd\git.exe -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse
2022/05/06 12:59:57 ...ules/context/repo.go:592:RepoAssignment() [E] RepoAssignment Invalid repo E:\APPS\Installations\gitea\data\git\repo\mbc\mbc_adminportal.git: exit status 128 - fatal: unsafe repository ('E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git' is owned by someone else)
	To add an exception for this directory, call:
	
		git config --global --add safe.directory E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git
	
2022/05/06 12:59:57 ...s/context/context.go:204:HTML() [D] Template: status/500

Things I tried

  • Running the Windows service with Administrator privileges
  • Upgraded the Gitea to latest version
  • Adding repo directory as Safe Repository by executing git config --global --add safe.directory E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git

Issue not resolved.

Gitea Version

1.13 & 1.16.6

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

giteaissue

Git Version

1.16.6

Operating System

Windows server 2019

How are you running Gitea?

Downloaded gitea build from official site. Running Gitea as Windows server using the command
sc.exe create gitea start= auto binPath= "\"E:\Installations\gitea\install\gitea.exe\" web --config \"E:\Installations\gitea\install\custom\conf\app.ini\""

Database

SQLite

Originally created by @Avinashachu007 on GitHub (May 6, 2022). ### Description I'm running a Gitea on-Premise for several years. Recently, When I access certain repositories, I get Internal server Error (500) in the Web UI. For those repo, I can't able to push or pull commit. More and More repositories are started giving the Error. I Noticed that Internal server error occurs, when I running gitea as Windows service. Below is the error from debug log.. Strangely When I run the Gitea.exe by Right click -> Run as Administrator, No errors. ``` 2022/05/06 12:59:44 ...s/context/context.go:204:HTML() [D] Template: status/500 2022/05/06 12:59:57 ...dules/git/command.go:146:RunWithContext() [D] E:\APPS\Installations\gitea\data\git\repo\mbc\mbc_adminportal.git: C:\Program Files\Git\cmd\git.exe -c credential.helper= -c protocol.version=2 -c uploadpack.allowfilter=true -c uploadpack.allowAnySHA1InWant=true -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse 2022/05/06 12:59:57 ...ules/context/repo.go:592:RepoAssignment() [E] RepoAssignment Invalid repo E:\APPS\Installations\gitea\data\git\repo\mbc\mbc_adminportal.git: exit status 128 - fatal: unsafe repository ('E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git 2022/05/06 12:59:57 ...s/context/context.go:204:HTML() [D] Template: status/500 ``` Things I tried - Running the Windows service with Administrator privileges - Upgraded the Gitea to latest version - Adding repo directory as Safe Repository by executing ` git config --global --add safe.directory E:/APPS/Installations/gitea/data/git/repo/mbc/mbc_adminportal.git ` Issue not resolved. ### Gitea Version 1.13 & 1.16.6 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![giteaissue](https://user-images.githubusercontent.com/12245421/167085742-07f93e72-6516-48c6-9402-0c09076c964e.png) ### Git Version 1.16.6 ### Operating System Windows server 2019 ### How are you running Gitea? Downloaded gitea build from official site. Running Gitea as Windows server using the command `sc.exe create gitea start= auto binPath= "\"E:\Installations\gitea\install\gitea.exe\" web --config \"E:\Installations\gitea\install\custom\conf\app.ini\""` ### Database SQLite
GiteaMirror added the type/bugissue/workaround labels 2025-11-02 08:23:09 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 6, 2022):

See this one:

Unfortunately, you can only bypass, no clear solution yet.

@wxiaoguang commented on GitHub (May 6, 2022): See this one: * https://github.com/go-gitea/gitea/issues/19455 * https://github.blog/2022-04-12-git-security-vulnerability-announced/ Unfortunately, you can only bypass, no clear solution yet.
Author
Owner

@singuliere commented on GitHub (May 8, 2022):

@Avinashachu007 this topic in the Gitea forum explains the manual actions you need to do fix the problem.

@singuliere commented on GitHub (May 8, 2022): @Avinashachu007 [this topic in the Gitea forum](https://discourse.gitea.io/t/upgrading-git-push-fails-due-to-changed-security-policy-safe-directory/5185) explains the manual actions you need to do fix the problem.
Author
Owner

@ve3 commented on GitHub (May 24, 2022):

I just have this problem when I re-install/clean-install new Windows.

Here is the fix:

  1. Replace owner for all files and folders included sub folders. See this answer on SO.
    1. Right click on Gitea folder.
    2. Click Properties > click Security tab > click Advanced.
    3. On the Owner line, click on Change.
    4. Type your user name and then click Check Names or add user name from Advanced button.
    5. Click OK to go back Advanced Security window.
    6. Tick the check box on Replace owner on subcontainers and objects.
    7. Click OK to all.
  2. In Windows Service, modify Gitea Logon by:
    1. Right click on Gitea service name.
    2. Click Properties > click Logon
    3. Use the same owner as in files and folders in step 1.
    4. Click OK to all.
  3. Restart Gitea service.

No need to run any safe.directory command. Try to Health check all repositories then access the repository again to see if they are working.

@ve3 commented on GitHub (May 24, 2022): I just have this problem when I re-install/clean-install new Windows. Here is the fix: 1. Replace owner for all files and folders included sub folders. See [this answer on SO](https://stackoverflow.com/a/71949648/128761). 1. Right click on **Gitea** folder. 2. Click **Properties** > click **Security** tab > click **Advanced**. 3. On the **Owner** line, click on **Change**. 4. Type your user name and then click **Check Names** or add user name from **Advanced** button. 5. Click OK to go back **Advanced Security** window. 6. Tick the check box on **Replace owner on subcontainers and objects**. 7. Click OK to all. 8. In Windows Service, modify Gitea **Logon** by: 1. Right click on **Gitea** service name. 3. Click **Properties** > click **Logon** 9. Use the same owner as in files and folders in step 1. 10. Click OK to all. 4. Restart Gitea service. No need to run any `safe.directory` command. Try to **Health check all repositories** then access the repository again to see if they are working.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8920