500 internal server error意思

500 internal server error意思

今天在用ajax请求数据的时候,突然出现了500错误,就很纳闷,平时都这么写的代码,怎么会突然报错,查了一下500错误的原因,应该是服务器的问题,有以下几种可能(现在把答案整理下来,避免下次犯同样的错误):

1、服务器资源超载

如果没对网站进行什么更改的话,最可能出现的一种情况。即当某一进程占用服务器太多资源的时候,会出现500错误,或者nginx如果开启了access log,太多的磁盘空间被占用,同样会出现500错误,建议在不需要的情况下,最好关闭access log。

2、nginx配置文件错误

这里不是指语法错误,nginx如果配置文件有语法错误,启动的时候就会提示。当配置rewrite的时候,有些规则处理不当会出现500错误,请仔细检查自己的rewrite规则。如果配置文件里有些变量设置不当,也会出现500错误,比如引用了一个没有值的变量。

3、文件权限设置错误

500错误还有可能是对文件设置了不正确的权限:

后台目录和文件的权限默认应该是755,而图片,文字等html文件应该是644,所以如果在刚刚上传文件后出现500错误,应该主要检查文件权限设置。

可以使用FTP软件选中所有文件,然后批量修改文件权限。

开始我以为是配置文件的问题,但好像改了也没用,各种方法都试过了,还是报同样的错误,在折腾了许久之后,偶然发现php代码在执行完数据库查询操作后没关闭数据库通道(此时还没意思到错误在这儿),于是添加了一行代码关闭数据库。

500 internal server error意思

当我再次请求时,突然发现没报错了,惊喜万分,回过头来想一想,终于发现了这个问题,我猜想应该是因为php代码在执行完数据库查询操作后没有关闭数据库,导致进程一直在占用服务器资源,于是出现了500错误,也就是上面说的第一种情况。

在查找过程中,看到这样一片帖子

500 internal server error意思
500 internal server error意思

刚开始还欣喜终于找到原因了,这个情况跟我很相似,以为这就是正确答案,结果我根本没怎么看懂,在服务器上也没找到webservices(我是小白,都不知道webservices是个啥东西,请原谅我的无知),最后白高兴一场,因为他错误的地方跟我根本就不一样!

今天把这个问题记录下来,避免下次犯下同样的错误,然后还得找半天。这也是我第一次做笔记,文笔不足,以后遇到这种问题,我都要学会记录下来。爬行在成为大牛的路上。。。

Troubleshooting an HTTP 500 internal server error is like solving a mystery.

500 internal server error意思

You don't know what exactly happened or why it happened — all you know is that something's wrong and you need to fix it.

500 internal server error意思

To guide you through the hassle of troubleshooting the dreaded HTTP 500 internal server error, let's go over what it exactly means and its most common causes and solutions.

An HTTP 500 internal server error is a general error message. It covers unexpected issues that don't fit into existing error codes. HTTP 500 errors are difficult to troubleshoot because a range of issues on the server side can trigger them.

Here are some examples of what a 500 error page might look like in your browser:

500 internal server error意思

500 internal server error意思

Image Source

500 internal server error意思

Image Source

HTTP 500

HTTP 500 errors aren't problems with your computer, browser, or internet connection. Instead, they're a generic response that catches any unexplainable server error. You'll see the HyperText Transfer Protocol (HTTP) 500 Internal Server Error when your server issue doesn't fit another error code.

Other Common Error Codes

HTTP codes show you how your web browser and website communicate. These are some other common error codes you might see on your website:

HTTP 200

This is a standard status code for websites that are performing well.

HTTP 301

This is the code for permanent redirects. For example, say you have two site pages about widgets with duplicate information and one gets more traffic than the other. It makes sense to redirect the low-traffic page to the high-traffic page to improve SEO for your site.

HTTP 302

This code is for temporary redirects. This is for situations where you want to send users to an alternate page for a short amount of time.

HTTP 304

This code shows up when the website you're requesting hasn't seen an update since your last visit.

HTTP 403

This code comes from the server when you're trying to access a restricted URL.

HTTP 404

A 404 code tells your users that your server can't find that page they requested with their browser. 404 errors are common, and some sites use this to their advantage.

HTTP 405

This is an HTTP response status code error. It tells you that a web browser wants to access your web page and your server has rejected that specific HTTP method. This means that the browser can’t access the requested web page.

HTTP 410

This is a permanent code that tells site visitors that the page they're looking for doesn't exist.

HTTP 413

This code appears when a user tries to upload a file that exceeds the server’s file size limit.

HTTP 429

This error is a server response to stop sending requests because of overloaded resources. This code might show up if your site needs to make too many API calls to meet a request.

HTTP 503

This code tells users that the server is temporarily unable to load the page they're looking for.

Check out this post for a comprehensive overview of error codes.

Potential Causes of a 500 Internal Server Error

A 500 internal server error is, as the name implies, a general problem with the website's server. More than likely, this means there's an issue or temporary glitch with the website's programming.

Some potential causes of a 500 internal server error include:

Corrupted or Broken .Htaccess File

A .htaccess file is a text file with important server instructions. These instructions tell your software to enable or disable specific functions. They might help you protect passwords in a directory or restrict user access.

There are many ways to corrupt a .htaccess file. It can happen during plugin installation, file configuration, or while you are working on your server.

A Permissions Error

Permission errors come with file protection. Permissions errors might be bugs, user mistakes, or networking problems. Usually, this error means that the user isn’t allowed to perform the action they're trying.

Faulty Third-Party Plugins or Themes

To increase user features and functionality, you might add a third-party theme or plugin to your website. These plugins can be great for your site, but they can also impact site security, bugs, and performance.

These plugins and themes are often created by individuals or small groups. This can be challenging because they may need more time to address bug fixes and vulnerabilities.

Exceeding the PHP Memory Limit

PHP is a server-side scripting language embedded in HTML. PHP is for managing content, databases, session tracking, and more. Each PHP process uses memory, and your hosting account has a limit for each one of these processes.

If a website needs more than this memory limit, you may see an HTTP 500 error.

HTTP Error 500 Browser Compatibility

Most businesses design their websites for maximum browser compatibility. This means that your website is easy to access and use on any browser or operating system. But your site may work perfectly in one browser and have issues or errors in others.

Because HTTP 500 is a catch-all error, you can see this error on any browser and in any operating system.

How an HTTP 500 Error Might Appear

This error can come up on any site you try to visit on a browser. Because it’s such a common error, there are many ways to communicate this code.

  • Internal server error
  • The page isn't working
  • 500 Internal Server Error
  • 500 Server Error
  • 500. That's an error.
  • HTTP 500.0 - Internal Server Error
  • Error 500
  • Error code: 500
  • The server returned a 500 Internal Server Error
  • Temporary Error (500)

How to Fix a 500 Internal Server Error

Unlike other server-side errors like a 502 code, a 500 internal server error is it doesn't immediately tell you what the problem is, nor does it tell you how to fix it. If the error persists for too long on your site, it could even negatively impact your SEO.

So, let's dive into some solutions so you can try to fix the issue.

If You're Trying to Load a Page with a 500 Internal Server Error:

1. Refresh the page.

This might seem obvious, but if it's a temporary loading issue, you might find success if you refresh the page. Before trying anything else in this list, reload the page and see what happens.

2. Come back later.

Since the error is on the server side, I'm willing to bet the website owners are working as quickly as possible to resolve the issue. Give it a few minutes or up to an hour or so, and then reload the URL and see if the development team has fixed the issue.

3. Delete your browser's cookies.

If clearing the browser history doesn't work, you might try deleting your browser's cookies. If the cookies are associated with the error-prone webpage, deleting the cookies might help reload the page.

4. Paste your URL into the website "Down for Everyone or Just Me."

Head to downforeveryoneorjustme.com and paste in the URL where you're seeing the internal server error. You'll either be told that the website is only down for you, or that the website is down for everyone.

500 internal server error意思
If it's a problem with your server, this should help assuage any concerns that it's an issue with your own computer.

If the 500 Internal Server Error is on Your Own Website:

1. Deactivate a plugin or theme.

Newly activated software, add-ons, or third-party scripts might be conflicting with your current server configuration. To determine this, try (carefully) deactivating or uninstalling your software add-ons one at a time to identify what exactly is causing the internal server error.

If you run a WordPress website, this is easy to do with plugins. From your dashboard, choose Plugins > Installed Plugins, then deactivate the first plugin. If the error resolves, you know this plugin is part of the issue. Reactivate the first plugin, then repeat this deactivate-reactivate process one at a time for all plugins to determine which ones are causing your error.

500 internal server error意思
You might find that having fewer active plugins on your site helps things run more smoothly.

Alternatively, if you just upgraded your software, your current plugins or themes might not be compatible with the new upgrade. Deactivating plugins or themes one at a time until the error disappears is the best way to find the root cause of your problem.

2. Use a plugin like WP Debugging to identify the issue.

If your site is powered by WordPress and you're comfortable with WordPress debugging processes, consider installing a plugin to help you identify the issue with your server.

The debug plugin WP Debugging, for instance, helps you figure out exactly what's wrong with your site, which will result in a speedier fix.

500 internal server error意思

Image Source

3. Ensure your PHP setup is configured correctly.

If the issue is related to a PHP timeout, consider creating timeout rules or error handling in your script to resolve the issue. Here's a full list of php.ini directives to configure your PHP setup.

Additionally, wrong permissions on a file or folder that has a script, like a PHP or CGI script, won't allow the script to run. Check your permissions and make sure you set them correctly on your server.

4. Check the code for your site's .htaccess file.

Incorrect coding or improper structure with your .htaccess file could be the reason you're seeing the 500 internal error. The .htaccess file helps you manage how long resources should be stored in a browser's cache. Try editing the file if you're seeing a 500 internal server error.

To locate your .htaccess file, access your website files through a file manager like cPanel or via FTP/SFTP. The file will probably be located in your public_html directory. There's a good chance your server will hide this file from view by default and you'll need to toggle hidden files on to see it.

500 internal server error意思

Image Source

Coding errors in .htaccess and custom scripts can also cause an HTTP 500 internal server error.

5. Ensure your new software is installed correctly.

Finally, check to see if your recently installed or upgraded software actually failed to install or upgrade. To refresh your software, check the vendor's website for instructions.

500 internal server error意思

Last Resort: Ask a Server Administrator for Help

If troubleshooting popular software problems or debugging server-side scripts doesn't fix your HTTP 500 internal server error, you should read about the most common causes for this type of issue in your server's documentation — an HTTP 500 internal server error can occur in different operating systems for a multitude of reasons.

You can also ask your service provider to access your error logs and find evidence of the root cause of your problem.

Internal server errors are irritating because they're unhelpful — it's basically the web server's way of saying, "Eh, I'm not sure." Hopefully, one of the above steps will resolve the problem so you can get back to life as usual.

Editor's note: This post was originally published in October 2018 and has been updated for comprehensiveness.

500 internal server error意思

如何解决500 Internal server error?

刷新页面解决500 Internal Server Error错误机会很少,但是仍然值得尝试。 尝试清除浏览器缓存。 如果显示500错误的页面被缓存,则清除缓存后,浏览器将请求该页面的新版本。 稍后再回来,网站管理员可能会在此期间解决服务器问题。

500是什么原因?

造成500错误常见原因有:ASP语法出错、ACCESS数据库连接语句出错、文件引用与包含路径出错(如未启用父路径)、使用了服务器不支持的组件如FSO等。 另解释:xp下ⅡS5.1无法执行ASP文件,错误! 500 内部连接错误|解决方法。

Server Error是什么意思?

internal server error错误通常发生在用户访问网页的时候发生,该错误的意思是因特网服务错误。 能够引起internal server error报错的原因有多个,如果你是网站主的话,可以对下列情形进行一一排查。

Request failed with Status Code 500是什么问题?

前后端分离的项目中前端利用post请求给后端发送数据,但是出现了错误:Error: Request failed with status code 500的错误我们要知道500代表(服务器内部错误) 服务器遇到错误,无法完成请求。