Server Error in '/' Application. erro:40【第二次修正140121】

本文介绍了两种常见的SQL连接错误解决方案:一是配置错误,通常出现在Web.config文件中数据库连接字符串的设置上;二是权限错误,涉及用户账户启用及文件夹权限设置。

解决方法:

方法一:配置错误

在网站目录下的Web.config里,连接数据库ip地址、数据库帐号、密码,可能没写好。

我是因为改了SQL默认端口,然后我把 " Data Source=IP " 里的IP直接用"点"代替。

举例:<add key="DBPlatformManager" value="Data Source=.; Initial Catalog=数据库名DB; User ID=明文帐号; Password=明文密码; Pooling=true"/>

方法二:权限错误

1.我的电脑 -- 右键 -- 管理 --用户管理 -- 用户 , 看看ISURE等用户是否启用。

2.在文件存放物理路径找到文件夹,给文件夹everyone用户权限。如下图。



以下是现实显示错误信息:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5005406
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   Game.Kernel.DbHelper.ExecuteDataset(CommandType commandType, String commandText, DbParameter[] commandParameters) +267
   Game.Kernel.DbHelper.ExecuteDataset(String commandText) +50
   Game.Kernel.DbHelper.ExecuteObjectList(String commandText) +61
   Game.Data.NativeWebDataProvider.GetTopNewsList(Int32 typeID, Int32 hot, Int32 elite, Int32 top) +487
   Game.Facade.NativeWebFacade.GetTopNewsList(Int32 typeID, Int32 hot, Int32 elite, Int32 top) +61
   Game.Web.Index.BindNewsData() +66
   Game.Web.Index.Page_Load(Object sender, EventArgs e) +82
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   Game.Facade.UCPageBase.OnLoad(EventArgs e) +44
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1966

Version Information: Microsoft .NET Framework Version:4.0.30128; ASP.NET Version:4.0.30128.1 


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

下面截图

#user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; # 代理方式 upstream backend { server 182.92.154.131; } # http server server { listen 80; server_name 182.92.154.131; location / { root /usr/share/nginx/html/dist; index index.html index.htm; # 解决history路由模式刷新404 try_files $uri $uri/ /index.html; } location /backend { # /backend/test/api /test/api proxy_pass http://backend:8080/; # 加/代表会丢弃/backend # proxy_pass backend; # 加/代表会丢弃/backend } # rewrite ^(.*)$ https://$host$1 permanent; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # HTTPS server # server { # listen 80; # server_name 182.92.154.131; # ssl_certificate /usr/share/nginx/https/8603727_182.92.154.131.pem; # ssl_certificate_key /usr/share/nginx/https/8603727_182.92.154.131.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root /usr/share/nginx/html/dist; # index index.html index.htm; # # 解决history路由模式刷新404 # try_files $uri $uri/ /index.html; # } # location /backend { # /backend/test/api /test/api # proxy_pass http://backend:8080/; # 加/代表会丢弃/backend # # proxy_pass backend; # 加/代表会丢弃/backend # } # error_page 500 502 503 504 /50x.html; # location = /50x.html { # root html; # } # } }[root@iZ2ze3k6buohug6id3eg97Z nginx]# docker logs -f nginx /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up 2025/03/24 03:53:01 [emerg] 1#1: upstream “backend” may not have port 8080 in /etc/nginx/nginx.conf:38 nginx: [emerg] upstream “backend” may not have port 8080 in /etc/nginx/nginx.conf:38 [root@iZ2ze3k6buohug6id3eg97Z nginx]# 分析一下日志
03-25
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 7.0. (called from instance_eval at E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/config/routes.rb:402) Exiting DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 7.0. (called from instance_eval at E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/config/routes.rb:402) E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/lib/rails/app_loader.rb:59:in `require': can't modify frozen SystemStackError (FrozenError) from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/lib/rails/app_loader.rb:59:in `block in exec_app' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/lib/rails/app_loader.rb:48:in `loop' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/lib/rails/app_loader.rb:48:in `exec_app' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/lib/rails/cli.rb:7:in `<top (required)>' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/exe/rails:10:in `require' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/vendor/bundle/ruby/2.6.0/gems/railties-6.1.7/exe/rails:10:in `<top (required)>' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/bin/rails:29:in `load' from E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/bin/rails:29:in `<main>' E:/Bitnami/redmine-5.0.3-0/apps/redmine/htdocs/bin/rails: stack level too deep (SystemStackError) Process finished with exit code 1
09-11
2025/10/27 15:39:57 [emerg] 46988#48720: "alias" directive is not allowed here in D:\yinghangJava\nginx-1.29.1/conf/nginx.conf:44 #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; server { listen 80; server_name yhxygl.yzu.edu.cn; # PC 应用根目录 root D:/yinghangJava/nginx-1.29.1/html/; index index.html index.htm; location / { try_files $uri $uri/ /index.html; } location ~ ^/assets/(.*)$ { # 根据 Referer 判断请求来源 if ($http_referer ~* "/h5_yh/") { alias D:/yinghangJava/h5/assets/$1; } if ($http_referer !~* "/h5_yh/") { alias D:/yinghangJava/nginx-1.29.1/html/assets/$1; } expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # PC 应用的静态资源 location /assets/ { alias D:/yinghangJava/nginx-1.29.1/html/assets/; expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # PC 应用的静态资源(如果存在static目录) location /static/ { alias D:/yinghangJava/nginx-1.29.1/html/static/; expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # H5应用配置 location /h5_yh/ { alias D:/yinghangJava/h5/; try_files $uri $uri/ /h5_yh/index.html; index index.html index.htm; # H5 的静态资源 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } } # 其他配置保持不变... location /ryplus_uni/ { rewrite ^/ryplus_uni/(.*)$ /$1 break; proxy_pass http://127.0.0.1:5500; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering on; proxy_redirect off; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 个我完整的修改代码
最新发布
10-28
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值