{"record":{"id":"e43e09d5448c9a9c","repo":"sj26/mailcatcher","slug":"error-something-s-using-port-port-are-you","errorCode":null,"errorMessage":"~~> ERROR: Something's using port #{port}. Are you already running MailCatcher?","messagePattern":"~~> ERROR: Something's using port #(.+?)\\. Are you already running MailCatcher\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/mail_catcher.rb","lineNumber":244,"sourceCode":"\nprotected\n\n  def smtp_url\n    \"smtp://#{@@options[:smtp_ip]}:#{@@options[:smtp_port]}\"\n  end\n\n  def http_url\n    \"http://#{@@options[:http_ip]}:#{@@options[:http_port]}#{@@options[:http_path]}\".chomp(\"/\")\n  end\n\n  def rescue_port port\n    begin\n      yield\n\n    # XXX: EventMachine only spits out RuntimeError with a string description\n    rescue RuntimeError\n      if $!.to_s =~ /\\bno acceptor\\b/\n        puts \"~~> ERROR: Something's using port #{port}. Are you already running MailCatcher?\"\n        puts \"==> #{smtp_url}\"\n        puts \"==> #{http_url}\"\n        exit -1\n      else\n        raise\n      end\n    end\n  end\nend\n","sourceCodeStart":226,"sourceCodeEnd":254,"githubUrl":"https://github.com/sj26/mailcatcher/blob/18a9cb7a79b321b2bcb51608dd793ea51255189e/lib/mail_catcher.rb#L226-L254","documentation":"MailCatcher failed to bind one of its two listeners (SMTP on 1025 or HTTP on 1080 by default) because the port is already taken. EventMachine raises only a bare RuntimeError with the text 'no acceptor', which rescue_port pattern-matches at lib/mail_catcher.rb:243, prints this message, and exits the process with status -1. Despite the wording, anything occupying the port triggers it, not just another MailCatcher instance.","triggerScenarios":"Starting `mailcatcher` when a previous daemonized instance is still running; another app bound to 1025/1080 (e.g. a dev SMTP server, nginx, or another Rails app's mailcatcher); starting MailCatcher twice in CI or docker-compose without unique ports; passing --smtp-port/--http-port (or --ip) values that collide with an existing listener, since both servers are started inside the single EventMachine.run loop (lib/mail_catcher.rb:182,189).","commonSituations":"MailCatcher daemonizes by default on non-Windows (:daemon => !windows?), so a forgotten background process silently holds the ports; two developers sharing a machine/VM; Docker containers with mirrored host ports; a crashed run whose socket lingers; ports below 1024 chosen without root.","solutions":["Find and stop the existing process: `lsof -i :1025 -i :1080` (or `ss -ltnp | grep -E '1025|1080'`), then kill the listed PID — or quit the old MailCatcher via DELETE http://127.0.0.1:1080/ from its web UI.","If the occupier is another MailCatcher you want gone: `pkill -f mailcatcher` or kill the daemon PID.","Run on different ports: `mailcatcher --smtp-port 1026 --http-port 1081`, and point your app's SMTP delivery at the new port.","If you actually need two instances, give each its own --ip/--smtp-port/--http-port combination."],"exampleFix":"# before\nmailcatcher\n# ~~> ERROR: Something's using port 1080. Are you already running MailCatcher?\n\n# after (option 1: free the port)\nlsof -ti :1025 -ti :1080 | xargs kill\nmailcatcher\n\n# after (option 2: pick free ports)\nmailcatcher --smtp-port 1026 --http-port 1081\n# then configure the app's SMTP client for localhost:1026","handlingStrategy":"validation","validationCode":"# Ruby: verify MailCatcher's ports are free before spawning it\nrequire \"socket\"\n\ndef port_free?(ip, port)\n  sock = TCPServer.new(ip, port)\n  true\nrescue Errno::EADDRINUSE, Errno::EACCES\n  false\nensure\n  sock&.close\nend\n\nsmtp_port, http_port = 1025, 1080\nunless port_free?(\"127.0.0.1\", smtp_port) && port_free?(\"127.0.0.1\", http_port)\n  abort \"port busy: pick others, e.g. mailcatcher --smtp-port #{smtp_port + 1} --http-port #{http_port + 1}\"\nend\n# shell alternative: lsof -i :1025 -i :1080","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember MailCatcher daemonizes by default on Unix — run it with --foreground in scripts so its lifetime is explicit.","In CI/docker, always pass explicit --smtp-port/--http-port per job/container to avoid collisions.","Quit instances through the web UI (DELETE /) or by killing the PID instead of leaving daemons behind.","When embedding MailCatcher via MailCatcher.run!, preflight-bind the chosen ports yourself before starting the reactor."],"tags":["port-conflict","address-in-use","eventmachine","startup","smtp","thin"],"backgroundTag":"address-in-use","analyzedSha":"18a9cb7a79b321b2bcb51608dd793ea51255189e","analyzedAt":"2026-08-21T18:56:10.605Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}