首先查看报错信息,日志位置:

/var/log/gitlab/gitlab-rails/production.log

1. 在登录时出现,相关报错信息:

** [Raven] Raven 0.15.6 configured not to send errors.
** [Raven] Raven 0.15.6 configured not to send errors.
Started POST "/users/sign_in" for *** at 2026-02-25 11:49:58 +0800
Processing by SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"login"=>"xxx@xxx.com", "password"=>"[FILTERED]", "remember_me"=>"1"}}
Completed 401 Unauthorized in 137ms (ActiveRecord: 7.3ms)
Processing by SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"login"=>"xxx@xxx.com", "password"=>"[FILTERED]", "remember_me"=>"1"}}
Completed 500 Internal Server Error in 96ms (ActiveRecord: 1.2ms)

BCrypt::Errors::InvalidHash (invalid hash):
  app/controllers/sessions_controller.rb:23:in `new'

注意此错误是由BCrypt引起,需要修改其源代码,参考我提供的路径,找到你的bcrypt下的engine文件

opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/bcrypt-3.1.10/lib/bcrypt# vim engine.rb

用vim修改第51行

- __bc_crypt(secret.to_s, salt)
+ __bc_crypt(secret.to_s, salt).gsub(/(\n|\x00).*/, '')

然后运行

gitlab-ctl reconfigure

gitlab-ctl restart

问题解决

2.在点击仓库时出现,相关报错信息:

Started GET "/***/***" for *** at 2026-02-25 12:16:08 +0800
Processing by ProjectsController#show as HTML
  Parameters: {"namespace_id"=>"***", "id"=>"***"}
Completed 500 Internal Server Error in 208ms (ActiveRecord: 14.1ms)

OpenSSL::Cipher::CipherError (bad decrypt):
  app/models/project.rb:383:in `import_url'
  app/models/project.rb:413:in `external_import?'
  app/models/project.rb:405:in `import?'
  app/models/project.rb:421:in `import_in_progress?'
  app/controllers/projects_controller.rb:93:in `show'
  lib/gitlab/middleware/go.rb:16:in `call'

此时需要把旧服务器gitlab的secret文件内容粘贴到新服务器中:

将旧的/etc/gitlab/gitlab-secrets.json的文件粘贴到新服务器/etc/gitlab/gitlab-secrets.json中,以防万一,注意备份文件。

运行

gitlab-ctl reconfigure

gitlab-ctl restart

问题解决

3.在点击“启用两步验证时”,相关报错信息:

Started GET "/profile/two_factor_auth/new" for 1*** at 2026-02-25 15:03:02 +0800
Processing by Profiles::TwoFactorAuthsController#new as HTML
Completed 500 Internal Server Error in 22ms (ActiveRecord: 0.5ms)

OpenSSL::Cipher::CipherError (bad decrypt):
  app/controllers/profiles/two_factor_auths_controller.rb:5:in `new'
  lib/gitlab/middleware/go.rb:16:in `call'

这种情况可能是在迁移过程中原来的两步验证信息丢失了,需要在数据库中将要操作的用户的两步验证的OTP 秘钥清空,对于gitlab 8.8.5:

gitlab-rails dbconsole

进入数据库环境,对于当前用户,通过邮箱来设置:

gitlabhq_production=> UPDATE users SET encrypted_otp_secret = NULL WHERE email = '***@***.com';
UPDATE 1

看到受影响的结果有1行

gitlab-ctl restart

再次点击两步验证,可以正常弹出二维码

问题解决

建议迁移前若启用两步验证,迁移后强制使用此方法关闭两步验证后再开启。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐