Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abkrim's avatar
Level 13

Connection refuse localhost:1025

I have a strange behavior today.

When I have gone to debug an project in which I use ray, suddenly I find myself with thousands of continuous lines, with the message

Connection could not be established with host localhost :stream_socket_client(): Unable to connect to localhost:1025 (Connection refused)
Handler.php:52

Ray

On my handler I have this:

public function register()
{
	$this->renderable(function (NotFoundHttpException $e, $request) {
		if ($request->is('api/*')) {
			return response()->json([
				'message' => 'Not found'
			], 404);
		}
	});


    // This block is line 52 
	$this->renderable(function (ModelNotFoundException $e, $request) {
		if ($request->is('api/*')) {
			return response()->json([
				'message' => 'Model not found'
			], 404);
		}
	});

	$this->reportable(function (Throwable $e) {
		//
	});
}

I do not understand the reason for this behavior, nor do I see why.

It happens to me in all projects.

And for me as a system administrator, that's an NFS port. Which drives me even crazier.

0 likes
6 replies
Tray2's avatar

Have you done any recent updates to your computer? Are you running windows?

1 like
sr57's avatar
sr57
Best Answer
Level 39

@abkrim

1025 should be your mailhog port, is it running? Try restart if yes

2 likes
abkrim's avatar
Level 13

Just a few moments ago I remembered that 1025 is mailhog, and that I just reinstalled my computer, and I have a project with a cron task that hadn't disabled cron, and so I was trying to send to mailhog and hadn't installed it yet.

Thanks to both of you.

sr57's avatar

@abkrim

A good practice is to keep a list with all the services/ports needed per app.

1 like
johndude's avatar

Got the same error message; as noted above the issue was that Mailhog wasn't running. On Mac I ran brew install mailhog followed by brew services run mailhog (as noted here in kittmedia, I'd include the link but I can't since I it's the first day I signed up for this site - ??) and the issue was resolved.

Please or to participate in this conversation.