Latest blog entry

Nginx 502 Bad Gateway error

October 30, 2011    |   Posted by admin   |    Category: Linux Administration

My server went down today and after restarting, it came up with a “Nginx 502 Bad Gateway” message. At first I thought its something related to the Nginx service, so restarted the nginx service but immediately realized it wasn’t the case.

Nginx receives a request on port 80 and it then proxies the request to ‘localhost’ on port 8080 (in my case) where another service is configured on it. If no service is listening on port 8080, it results in a ‘Nginx 502 Bad gateway’ message. I immediately realized it was the Java service binded on port 8080 of my server and started it.

# java -jar /home/user/test.jar

The website was online immediately.

The Nginx proxy port is defined in the Nginx configuration file and different services could be binded to the proxy port depending on your setup. It could be

1) PHP-fpm
2) php_cgi
3) FastCGI

OR could be something else. You have to start the service listening on the proxy port to get your website/application online.

Comments Off on Nginx 502 Bad Gateway error

Unable to start SSH: /dev/null is not a character device

October 6, 2011    |   Posted by admin   |    Category: VPS Management

The “/dev/null is not a character device” message occurs in a VPS when an upgrade is performed and the /dev/null turns into a regular file.

# /etc/init.d/sshd restart
Restarting Secure Shell server: sshd failed!
/dev/null is not a character device!.

The /dev/null should be a character device as per the Linux standards. To fix the issue, remove the file

# rm -f /dev/null

Create the character device

# mknod /dev/null c 1 3

The file should look like follows:

# ls -la /dev/null
crw-rw-rw- 1 root root 1, 3 Oct  1 11:42 /dev/null

Now restart the sshd service

# /etc/init.d/sshd restart
Stopping sshd:              [  OK  ]
Starting sshd:              [  OK  ]
Comments Off on Unable to start SSH: /dev/null is not a character device