34

I'm trying to run "foreman start" for a rails app however this error message is preventing me from running the foreman properly:

~~> ERROR: Something's using port 1025. Are you already running MailCatcher?

I've tried killing the PID, going to the web interface to quit the program and also...restarting the comp. Does anybody know how to remedy this?

Thanks

CJ -S
  • 353
  • 1
  • 3
  • 6
  • 1
    Are you running an NFS? [According to Wikipedia](http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Registered_ports), NFS will use that port. –  Dec 13 '14 at 08:43
  • @MisterDood you right. I'm using NFS alongside my vagrant box and when deactivate the NFS syncing, the error message went off. Pretty weird given I've done this same conf in a MBP (same vagrant box). – Francisco Quintero May 24 '16 at 03:50

10 Answers10

49

In OSX, run the following in a shell:

sudo lsof -nP -iTCP:1025 -sTCP:LISTEN

The expected output of this command is a process, which is listening on port 1025:

ruby    43841 youruserid    9u  IPv4 0x6a1610da80bb9b4f      0t0  TCP 127.0.0.1:1025 (LISTEN)

In the output above, the 2nd value is the process ID. Then, to kill the offending process (substitute in the correct PID):

sudo kill 43841
Joseph Combs
  • 909
  • 9
  • 12
19

MailCatcher launches both SMTP and HTTP servers.

When you start MailCatcher in a terminal you'll see the following output:

$ mailcatcher
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

See the last line in the output when starting MailCatcher?

If you attempt to start MailCatcher if it's already running you'll see:

$ mailcatcher
Starting MailCatcher
~~> ERROR: Something's using port 1025. Are you already running MailCatcher?

How to quit Mailcatcher:

  1. Open the http url (http://127.0.0.1:1080) in your browser.

    Note: the port may be different than 1080. If so, you'll have to use that port. If you don't know it, you'll have to use one of the other answers here to kill the running process.

  2. In the top right corner of the page that opens, you'll see a "Quit" link.

How to Quit MailCatcher

Beau Smith
  • 33,433
  • 13
  • 94
  • 101
10

If you are using linux, you should be able to see what program is using a certain port using the netstat command. To see if port 1025 is in use, run this from the command line:

$ netstat -tulpn | grep :1025

Here is a useful reference: http://www.cyberciti.biz/faq/what-process-has-open-linux-port/

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
saskcan
  • 178
  • 6
  • 1
    I've executed the command with lsof|grep :1025. Killed th e PID with kill -9 PID. However I'm still getting the error. Thanks though! – CJ -S Jul 18 '14 at 19:33
4

get the process id's of the ports mailcatcher is using

lsof -i tcp:1080 
lsof -i tcp:1025

kill em:

kill 37747 
kill 35647
Jbur43
  • 1,284
  • 17
  • 38
3

I solved this by starting mailcatcher on a different port: mailcatcher --smtp-port 1026

And changing the following in config/development.rb

config.action_mailer.smtp_settings = {
  ...
  port: 1026,
  ...
}
Linus
  • 4,643
  • 8
  • 49
  • 74
  • I'm on Windows, it doesn't help with port `1026` or `1027` etc. But it lead me in the right direction. Didn't think of just simply changing the port. It works with `--smtp-port 30000` for me, Windows 7. Found it here https://block81.com/articles/test-emails-locally-with-mailcatcher – 244an Apr 22 '18 at 11:53
1

To avoid that type of situation use mailcatcher in a container. You can find few in docker hub, here is my cut.

Stephane Paquet
  • 2,315
  • 27
  • 31
0

Try launchctl remove me.mailcatcher

airdrumz
  • 429
  • 4
  • 9
0

A good advice. If you already have somehow "postfix" configured or running just stop it in order to get the mails in "Mail Catcher"

sudo systemctl stop postfix
0

Putting this here in case it helps someone else.

I made the mistake of visiting http://localhost:1025/, whereas I needed to be at http://localhost:1080/.

Go to http://localhost:1080/ and hopefully mailcatcher is running as expected

stevec
  • 41,291
  • 27
  • 223
  • 311
0

Another way to kill MailCatcher in this situation, if you are using a Mac:

Manually stop all ruby processes that you are running locally, and then open Activity Monitor, by pressing Command + Space (to bring up Spotlight) and type "Activity Monitor" to find and open the application.

In Activity Monitor, sort the processes by Process Name. Look for any processes named ruby that remain running:

Image showing processed named 'ruby' in Activity Monitor

Click on any process that you are interested in killing, and click the Stop Process button at the top of the window.

Image showing button image with "X" labeled "Stop"

After manually stopping all ruby processes and then killing any remaining ruby processes in this manner, you should then be able to run MailCatcher successfully.

LHM
  • 721
  • 12
  • 31