Monday, May 20, 2019

Dovecot Is Not Running





Check for Running Processes

First check to see if dovecot is currently running:
root@server [~]# ps -flC dovecot
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
5 S root 14919 1 0 85 5 - 2666 - 00:36 ? 00:00:03 /usr/sbin/dovecot

Service Availability

If a processes exists, check that the service is listening:

Checking Port 110:

[root@server ~]# fuser 110/tcp
110/tcp: 22127 23159 25144
Checking Port 143:
[root@server ~]# fuser 143/tcp143/tcp: 23487 256590 25543


You can use lsof -i command too, like lsof -i :110 etc ..

Resolution:

Restarting Dovecot

Regardless, restart the service to bring it back online quickly.


[root@server ~]# /etc/init.d/dovecot restart
Stopping Dovecot Imap: [ OK ]
Starting Dovecot Imap: [ OK ]
If it fails to start, watch for errors in /var/log/maillog


If nothing useful is logged there, then attempt to run the dovecot binary manually.

Running Dovecot From Binary:

[root@server ~]# /usr/sbin/dovecot

If there are any errors, they will then be logged to our terminal.

Common Errors

Error: service(auth): Socket already exists: /var/run/dovecot/auth-*

Occasionally we will find that Dovecot will not start due to various socket files left behind when it was terminated. The following will remove all associated socket files and allow us to restart Dovecot.


Removing Socket Files:

root@server [~]# rm -fv /var/run/dovecot/auth-{login,client,userdb,master}
removed `/var/run/dovecot/auth-login'
removed `/var/run/dovecot/auth-client'
removed `/var/run/dovecot/auth-userdb'
removed `/var/run/dovecot/auth-master'

You can also kill any running dovecot process and restart it too


root@server [~]#ps fauxxw | grep dovecot | grep -v grep | awk '{print $2}' | xargs kill -9 ; /etc/init.d/dovecot restart

Sunday, May 19, 2019

FTP Service Down (pure-ftpd)



This is the process of checking the "pure-ftpd" service on cpanel servers and restarting it accordingly.
 

Checking Service Status


First check the services status to ensure it is running.

root@server [~]# /etc/init.d/pure-ftpd statuspure-ftpd (pid 934) is running...+------+---------+-------+------+-------------------------------------------+| PID | Login |For/Spd| What | File/IP |+------+---------+-------+------+-------------------------------------------+

Here we can also see that it has the PID of 934, which we can additionally verify to ensure that it is not simply a stale PID:

root@server [~]# ps -clf 934
F S UID PID PPID CLS PRI ADDR SZ WCHAN STIME TTY TIME CMD
5 S root 934 1 TS 19 - 9571 poll_s Feb07 ? 0:29 pure-ftpd (SERVER)

Checking That Service Is Listening


The FTP service listens on port 21. We can use fuser to check if it listening on the server.
Checking for Port Listening


root@server [~]# fuser 21/tcp
or

root@server [~]# lsof -i :21

Checking External Accessibility

While the port may be listening on the server, we will want to additionally check if we are able to connect to it. 

Successful External Connection:

user@workstation [~]$ ftp server.example.com Connected to server.example.com.220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------220-You are user number 3 of 150 allowed.220-Local time is now 22:14. Server port: 21.220-IPv6 connections are also welcome on this server.220 You will be disconnected after 15 minutes of inactivity.Name (server.example.com:user):

If we find that the service is listening, but not accessible externally then restart the firewall accordingly.

Resolution

Restarting FTP

To restart the service use the following:
Restarting the service:

root@server [~]# /etc/init.d/pure-ftpd restart
Stopping pure-config.pl:Stopping pure-authd: 1 process (pure-authd) sent signal 9
Starting pure-config.pl: Running: /usr/sbin/pure-ftpd -O clf:/var/log/xferlog --daemonize -A -c50 -B -C8 -D -E -fftp -H -I15 -lextauth:/var/run/ftpd.sock -L10000:8 -m4 -s -S21 -U133:022 -u100 -i -Oxferlog:/usr/local/apache/domlogs/ftpxferlog -k99 -Z -Y1 -JHIGH:MEDIUM:+TLSv1:!SSLv2:+SSLv3 [ OK ]
Starting pure-authd:


Note: If you are have anyother ftp service like vsftp or proftp you need to adjust restart command accordingly.

Dovecot Is Not Running