mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-14 11:56:41 -05:00
ORM fails to connect - Login error with MSSQL #4844
Closed
opened 2025-11-02 06:04:37 -06:00 by GiteaMirror
·
33 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.5
v1.16.4
v1.16.3
v1.16.2
v1.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.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
issue/needs-feedback
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#4844
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 @commel on GitHub (Feb 13, 2020).
Gitea version (or commit ref): 1.11.0 release
Git version: 2.24.0.windows.1
Operating system: Windows Server 2019 Datacenter Version 1809
Database (use
[x]):Can you reproduce the bug at https://try.gitea.io:
Log gist:
https://gist.github.com/commel/4f0d03f6f82b25688fb32f1cf2f2a8e8
Description
Starting gitea fails with 1.11.0, the log claims that the password to the MSSQL server is incorrect. Login and Deploy with same config works on previous releases 1.10.3 and 1.9.6. Login with the gitea credentials also work on MSSMS.
This is the configuration:
@bagasme commented on GitHub (Feb 13, 2020):
@commel can you connect to DB host?
@lunny commented on GitHub (Feb 13, 2020):
What's your MSSQL server version?
@commel commented on GitHub (Feb 13, 2020):
@lunny The connected server is a SQL Server 2014 (Version 12.0.2000.8)
@bagasme As I wrote: I can connect with older gitea versions, and with Microsoft SQL Server Management Studio using the credentials in the gitea.ini.
@lunny commented on GitHub (Feb 13, 2020):
Which latest version you can work with this MSSQL instance?
@commel commented on GitHub (Feb 13, 2020):
@lunny: Gitea 1.10.3 works fine
@guillep2k commented on GitHub (Feb 13, 2020):
Just in case. Try:
@commel commented on GitHub (Feb 14, 2020):
@guillep2k thanks, i gave it a try, sadly that notation does not work either with 1.10.3 or 1.11
@c-key commented on GitHub (Feb 14, 2020):
I have the same issue. Gitea can not connect to our MS SQL express database.
Git-Version: 2.25.0
Gitea-Version: 1.11.0
OS-Version: Windows Server 2016 1607
I connection through MS SQL Server Management Studio is possible. I tried in the app.ini from Gitea the host-string "machinename\dbinstance", ".\dbinstance" and also th tip with the escaped "". Nothing works.
Maybe it depends to #8536
@lunny commented on GitHub (Feb 14, 2020):
I think this should be a configuration problem, because CI with mssql integration tests succeed.
@c-key commented on GitHub (Feb 14, 2020):
Which configuration is set on CI with mssql integration? So we can check our configuration on mssql and server side.
@c-key commented on GitHub (Feb 17, 2020):
But why it is woking with the previous version of gitea under 1.11.0
@lunny commented on GitHub (Feb 18, 2020):
I think it maybe related with we have upgraded mssql driver on v1.11.0
@cht47 commented on GitHub (Mar 2, 2020):
1.11 also doesn't start with PostgreSQL 10 on the same machine. (CentOS 7)
Different DB, different OS, this is a major issue and should be fixed soon.
@guillep2k commented on GitHub (Mar 3, 2020):
I'm using PostgreSQL 9.6.16 on CentOS 7 and 1.11 works fine for me. I'm using:
@commel commented on GitHub (Mar 11, 2020):
Just wanted to let you know that the problem remains with the newest updates of Gitea 1.11.3. The current update of the 1.10-branch to 1.10.6 still works.
@stale[bot] commented on GitHub (May 10, 2020):
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
@6543 commented on GitHub (May 10, 2020):
gitea 1.10 branch use:
gitea >= 1.11 use:
so an update may help?
@6543 commented on GitHub (May 10, 2020):
@commel can you test current master for us?
@commel commented on GitHub (May 11, 2020):
Sure, happy to help. Just tried the master binary from 05/11/2020 12:51:35 AM +00:00, but this one still has the same problem. :-(
@6543 commented on GitHub (May 11, 2020):
thanks for testing ...
@guillep2k commented on GitHub (May 20, 2020):
@commel Some users could fix this issue by changing the connection string escaping the backslash (e.g.
127.0.0.1\dbinstance-->127.0.0.1\\dbinstance); this is due to a library update we did a while ago. Can you check if this is your case?@jeffest commented on GitHub (May 21, 2020):
just downloaded and launched v1.12. Using MSSQL 2016 with named instance is having the same issue. Using the IP or escaping the backslash didn't help.
Is there anyway to have a detailed log ? Tried to put XORM log level to Debug but that didn't help.
@guillep2k commented on GitHub (May 22, 2020):
Have you tried with
sqlcmdfrom the command box to see what happens?:The first version should work if the instance name is not the default from SQL Server (e.g. not
SQLEXPRESS). Otherwise, the second version should work and you should be using justHOST = 127.0.0.1(with no instance specified).I know you've already tried with SQL Management Studio, but that test is indeterminate because it tries different routes (named pipes, etc.), and we want to check only if this particular route works.
@jeffest commented on GitHub (May 22, 2020):
I just did and it works just fine. Compared to your guess above (and that might help you), my SQL Server is not on localhost and this is not a SQLEXPRESS edition.
Thank you anyway for your help.
@guillep2k commented on GitHub (May 22, 2020):
Did you run
sqlcmdon the host with the database or on the host running Gitea?@jeffest commented on GitHub (May 22, 2020):
On the host running Gitea
@guillep2k commented on GitHub (May 22, 2020):
@jeffest Since you're not the OP of the issue, let me ask a couple of questions:
Finally... it would be great if you could use a tool like Wireshark to spy the network and check if a connection is being attempted or not even that (you can repeat the
sqlcmdtest to have a sample of what the connection attempt should look like). The filter you're interested in istcp.port == 1433.@jeffest commented on GitHub (May 25, 2020):
@guillep2k, it's a brand new instance and, btw, I'm brand new to Gitea.
Yes the database already exists along with a dedicated user and associated access rights.
As for the logs, even though I was in DEBUG level they were pretty useless as none of the logged event were coming from the MSSQL driver itself. But It is very likely that I did not configure the Gitea's logging feature properly.
Also, I had to move on for my project, so I switched to mysql driver (all good first try !). But, I will install another instance of Gitea on the same machine and will get you the logs. I will also try the network sniffing.
What I can tell you for sure is that a connection is in fact attempted. To test that, I removed the db's username and password to "force" the driver to go with Windows authentication. Which it did and the error message was different this time (fyi, my Windows user is sysadmin on the SQLServer).
@jeffest commented on GitHub (May 25, 2020):
Here is what I get in Gitea's log :
2020/05/25 09:33:57 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] select name from sysobjects where xtype ='U' [] - 90.9985ms /go/src/code.gitea.io/gitea/vendor/xorm.io/xorm/core/db.go:154 (0xb92d2b) /go/src/code.gitea.io/gitea/vendor/xorm.io/xorm/dialects/mssql.go:408 (0xba22ee) /go/src/code.gitea.io/gitea/vendor/xorm.io/xorm/session_schema.go:236 (0xc143e9) /go/src/code.gitea.io/gitea/models/models.go:163 (0x107750a) /go/src/code.gitea.io/gitea/routers/install.go:165 (0x1976292)From the UI, with "forced" Windows Authentication I get the following message :
With login/password I get the following:
This leads me to another possibility. The server I'm trying to connect to is hosting multiple versions of SQL Server. The default instance is SQL Server 2014, then I have named instances for 2008, 2012 and 2016. I was wondering if the MSSQL driver was compatible with the dynamic port assignment technique used by SQL Server.
@jeffest commented on GitHub (May 25, 2020):
@guillep2k, I think my assumption above is correct. The driver only connects to SQL Server on port 1433 which in my case is the default SQL Server instance (i.e. not the one I target). I've checked the logs on that server and I saw the failed login attempts for user 'gitea'.
To go further, I retrieved the dynamic port number used by my named instance and passed it to Gitea's install screen in this format:
<server>\<instance name>:<port>and this time Gitea successfully logged on and completed the installation process.As SQL Server will always use the same dynamic port unless already in use when the engine start, I'll keep my config as-is for now.
As for the GO mssql driver, it should be aware of possible use of dynamic port assignment and first query the SQL Server's Browser service to obtain the port number used by the named instance.
Let me know if you need further details. If I can provide them I'll be happy to help.
@jeffest commented on GitHub (May 25, 2020):
@commel, can you please try to obtain the port number used by your instance of SQL Server and try to put that port number in Gitea's ini file ?
HOST = host\dbinstance:portI just want to find out if my findings will help you out or if our problems have different sources.
Obviously in my case I cannot test with a previous version of Gitea as this is my first install.
@guillep2k commented on GitHub (May 26, 2020):
@jeffest Good hunting! I'd never have thought of a multiple instances scenario. 👍
@commel commented on GitHub (May 26, 2020):
@jeffest Great Catch! That did it! The company server in fact has multiple SQL server instances running. I have no direct access to the server itself to find the port so I connected with MSSQL Management Studio and queries the master database with:
which i added to the gitea.ini:
I was able to successfully connect. Then I upgraded to my last tried version (to verify this is the fix and not some update from a later version), which was 1.11.3. Then I've upgraded to 1.11.5.
All running now, thank you very much, everybody, specially @lunny, @guillep2k and @jeffest!