Cannot upload new file from web interface and automated backups


Hello everyone,

First of all, I’m quite a bit of a noob when it comes to Git. But as I’m the one that is the less scared in server administration in my group, I’ve been hosting the git repositories for a group project.

I’m running Gogs Version:, with mysql as a database.
All of that is running on Debian 9 Strech.

The problem is :
On a specific repository, it is impossible to upload a file through the web interface to any of the branches.
I’ve tested this on multiple accounts.
I can create a new file and commit.
I can modify a file and commit.
I can upload a file via command line and commit.

I’ve set the logs to Trace, and I can see this when uploading a file :

Template: status/404

But no 404 page on the browser, it will just return back to the repository as it was before adding the file.

I’ve tried restarting the server : did not work
I haven’t tried reinstalling the whole thing and restoring a backup. May try in a VM to see if it works.

I can provide anything that will be able to help me resolve this issue.

On another note, I can’t seem to be able to use the backup option via cron.

the crontab entry is :
0 1,9,12,15,17 * * * /home/tanguy/

the script launched by cron is at follows :


cd /home/tanguy/backupGogs && /home/tanguy/gogs/gogs/gogs backup
date > date.log

I can see the date change, but no backup is created.

Thanks for taking the time to read all of this. If you have any idea for either of the issues, I’ll be happy to test them out.




Can you reproduce on



This post was flagged by the community and is temporarily hidden.



OK, so I’ve restored a backup to a virtual machine, and I can replicate this problem. Still can’t upload to the repository. This might be a repo error rather than a gogs error, but I can’t figure out why its doing that.
Just tried, temporary fix for this can be to mirror the repo to my repositories, deleting the repo from the organisation, and the mirroring back the repo from my things to the organisation.

I can provide the backup file if you want.



I think it is because the upload request sent to a 404 URL path. Can you open the Chrome web console see the request path the browser was trying to send to?



This post was flagged by the community and is temporarily hidden.



Same response but succeed on

Trace is the most detailed log level. And what you received is 404, which means the Gogs router couldn’t find a handler to handle the request thus no log will be generated unfortunately.



Same response but succeed on [Link that I cannot post for obscure reasons] ?


also, why the hell are my messages flagged ? I am doing something wrong here ?



I guess maybe it could be your reverse proxy problem?

The system automatically flags because the user level setting something.



What is strange is that it only happens on this repository. On everything else, it works fine. Plus restoring the backup on a VM and using localhost:3000 yielded the same results



You mean upload the exactly the same file, only occurs problem on this particular repository?



I mean the repository yes, sorry



Sounds like there is something unique about this problematic repository but I don’t have any ideas right now…



If that can help, it happened around the time we merged a branch into master.

Also, do you know why I can’t launch the gogs backup via cron ?



I do not know, you should find your script logs, not to guess why.



I’ll leave it here if anyone get the same problem :
Expect user git but current user is ""
For cron to be running the backup job, it has to have the same username as the one in the config file.
However, cron does not carry all environment variables. The way I got it to work is to have my cron job like this :

0 1,9-18 * * * export USER="_username_in_config_"; sh

Otherwise, gogs will return an error since it gets the username like that:

func CurrentUsername() string {
	curUserName := os.Getenv("USER")
	if len(curUserName) > 0 {
		return curUserName

	return os.Getenv("USERNAME")

and since either USER and USERNAME were not defined, it was just a blank string, hence the error.
I’m surely not doing this right, but it works for me.



Yes you should set one of these environment variables.



alright so it happened again.

I don’t know what is causing it.

Only feature not working as of now is uploading files through web interface. Everything else works as it should.