Nginxが起動できない時の対処法【XServer VPS】

FirefoxでPR_CONNECT_RESET_ERROR、ChromeでERR_CONNECTION_RESETとエラーコードが表示されていました。

systemctl status nginxコマンドで確認してみると、Nginxの起動に失敗していました。

php
# systemctl status nginx
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en>
     Active: failed (Result: exit-code) since Wed 2025-07-16 20:42:10 JST; 4min>
 Invocation: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       Docs: man:nginx(8)
    Process: 802 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proces>
   Mem peak: 3.2M
        CPU: 13ms

 7月 16 20:42:10 x systemd[1]: Starting nginx.service - A high p>
 7月 16 20:42:10 x nginx[802]: 2025/07/16 20:42:10 [emerg] 802#8>
 7月 16 20:42:10 x nginx[802]: nginx: configuration file /etc/ng>
 7月 16 20:42:10 x systemd[1]: nginx.service: Control process ex>
 7月 16 20:42:10 x systemd[1]: nginx.service: Failed with result>
 7月 16 20:42:10 x systemd[1]: Failed to start nginx.service - A>

今回のNginxの起動の失敗は、defaultファイルによるものでした。

php
# nginx -t
2025/07/16 20:48:30 [emerg] 1159#1159: unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:106
nginx: configuration file /etc/nginx/nginx.conf test failed

確認してみると、ファイル末尾の位置に半角スペースがありました。

php
server {
	listen 80;
	listen [::]:80;

	server_name example.com;

	root /var/www/example.com;
	index index.html;

	location / {
		try_files $uri $uri/ =404;
	}
}

このファイル末尾にある半角スペースを削除するとNginxが起動できるようになりました。

※補足
FirefoxでPR_CONNECT_RESET_ERROR、ChromeでERR_CONNECTION_RESETとエラーコードが表示される原因として、HTTPのみ対応しているのにHTTPSでアクセスしていることもあります。

関連記事