Nginx service 500: Internal Server Error one of the reasons

Nginx service 500: Internal Server Error one of the reasons

500 (Internal Server Error) The server encountered an error and could not complete the request.
501 (Not Implemented) The server does not have the functionality to complete the request. For example, a server might return this code when the server does not recognize the request method.
502 (Bad Gateway) The server, while acting as a gateway or proxy, received an invalid response from an upstream server.
503 (Service Unavailable) The server is currently unavailable (either because it is overloaded or down for maintenance). Usually, this is only a temporary condition.
504 (Gateway Timeout) The server, acting as a gateway or proxy, did not receive a request from an upstream server in a timely manner.
505 (HTTP Version Not Supported) The server does not support the HTTP protocol version used in the request.
Nginx 500 error (Internal Server Error): A 500 error refers to an internal server error, which means that the server encountered an unexpected situation and was unable to fulfill the request.

In the case of high concurrent connections, Nginx is a good alternative to Apache server. Nginx can also be used as a layer 7 load balancing server. According to the test results, Nginx 0.6.31 + PHP 5.2.6 (FastCGI) can handle more than 30,000 concurrent connections, which is 10 times that of Apache under the same environment.

But many people will encounter 500 errors when using Nginx. According to my experience, there are the following situations.

1. Is there insufficient disk space?

Use df -k to check whether the hard disk space is full. Clearing up hard drive space can resolve 500 errors. If nginx has access log enabled, it is best to disable access log if it is not needed. The access log will take up a lot of hard disk space.

2. Is the nginx configuration file wrong?

This does not refer to syntax errors. If there are syntax errors in the nginx configuration file, it will be prompted when it is started. When configuring rewrite, some rules may not be handled properly and a 500 error may occur. Please check your rewrite rules carefully. A 500 error may also occur if some variables in the configuration file are not set correctly, such as referencing a variable that has no value.

3. If none of the above problems exist, it may be that the number of simulated concurrency is too large, and you need to adjust the concurrency setting number of nginx.conf

4. Another problem is that the Linux index node (inode) is full and causes failure. df -i

There could be many reasons, I just record the ones I encountered.

500, internal server error, may actually be an error caused at the code level.

First, check the ngnix or Apache error log, and then check the error log. You can basically find the cause of the error based on the error log, or search the error log on Google or Baidu.

Secondly, you can view the error log information of the framework, such as laravel.log.

sudo find / -name '*.log' 
or 
cd /var/log/nginx/ && ls 

cat /var/log/nginx/newdns.com-error.log 

Summary: The error I encountered this time was because my MySQL table did not have the `updated_at`, `created_at` fields, and was not set in the Laravel framework model

public $timestamps = false; , I wrote the wrong path when rewriting the exception handler Exception, which caused MySQL to throw an error. The framework exception handler could not handle it, so it ran to the server, causing the server to hang. I was devastated.

This is the end of this article about Nginx service 500: Internal Server Error, one of the reasons. For more information about Nginx service 500 error, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of PHP+nginx service 500 502 error troubleshooting ideas

<<:  Data storage implementation method in WeChat applet

>>:  Solve the MySQL login 1045 problem under centos

Recommend

Web Design Tutorial (2): On Imitation and Plagiarism

<br />In the previous article, I introduced ...

DOCTYPE element detailed explanation complete version

1. Overview This article systematically explains ...

Detailed discussion of the differences between loops in JavaScript

Table of contents Preface Enumerable properties I...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

How to implement nested if method in nginx

Nginx does not support nested if statements, nor ...

Detailed explanation of Axios asynchronous communication in Vue

1. First, we create a .json file for interactive ...

Example of MySQL slow query

Introduction By enabling the slow query log, MySQ...

Understanding and using callback functions in JavaScript

Table of contents Overview What are callbacks or ...

Navigation Design and Information Architecture

<br />Most of the time when we talk about na...

JavaScript method to detect the type of file

Table of contents 1. How to view the binary data ...

Mysql database recovery actual record by time point

Introduction: MySQL database recovery by time poi...

JavaScript implements single linked list process analysis

Preface: To store multiple elements, arrays are t...

JavaScript quickly implements calendar effects

This article example shares the specific code of ...