Laravel Homestead Mailhog Error listening on socket: listen tcp 0.0.0.0:1025: bind: address already in use - homestead

I am struggling to make MailHog work in my Laravel Homestead VM.
If I browse http://localhost:8025/, the web browser says it can't find it.
Then, in the command line, when executing $ mailhog, I get the following error:
Error listening on socket: listen tcp 0.0.0.0:1025: bind: address
already in use
Moreover, if I execute $ mailhog --invite-jim then I get:
2021/09/13 22:49:22 Using in-memory storage 2021/09/13 22:49:22 [SMTP]
Binding to address: 0.0.0.0:1025 [HTTP] Binding to address:
0.0.0.0:8025 2021/09/13 22:49:22 Serving under http://0.0.0.0:8025/ 2021/09/13 22:49:22 [SMTP] Error listening on socket: listen tcp
0.0.0.0:1025: bind: address already in use
Here is my .env config file
.env
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=reply#app.io
MAIL_FROM_NAME="${APP_NAME}"
Does anyone know or can shed some light how to make MailHog work?

Mailhog web interface is clearly listening at the 8025 port. The localhost or 127.0.0.1 address may not work by default.
Take a look at both the /etc/hosts and Homestead.yml file
$ sudo vim /etc/hosts
$ vim Homestead.yml
Look for the address that Homestead is working on. In this case it's 192.168.10.10 or 192.168.56.56
So now try
http://192.168.10.10:8025 or http://192.168.56.56:8025
And it should be working now

Related

HTTP Loopback Connections are not enabled on this server - wordpress on docker

I have a wordpress official container with a dock port 80 mapped to 32795 external... when I go to administration area of wordpress I get this error:
Important: HTTP Loopback Connections are not enabled on this server. If you need to contact your web host, tell them that when PHP tries to connect back to the site at the URL http://localhost:32795/wp-admin/admin-ajax.php and it gets the error cURL error 7: Failed to connect to localhost port 32795: Connection refused. There may be a problem with the server configuration (eg local DNS problems, mod_security, etc) preventing connections from working properly.
I think the problem is that the site inside the container tries to communicate with the 32795 port instead of 80, but it can not because this door is only seen from the outside of the container...
I created a script inside the site with phpinfo, and I checked the loopback connections are on...
There is a solution for this? I have docker un windows with kitematic
thanks
I had a similar problem running WordPress with Nginx on Docker Desktop for Windows. I needed to add an entry to the container's hosts file that directed my local.example.com domain to hit my ingress-nginx controller so that WordPress' loopback requests would work. Although my setup might be slightly different this might help you.
Open /Windows/System32/drivers/etc/hosts and copy the IP address that's next to host.docker.internal. Add an entry to the container's hosts file on startup that ties the domain to the hosts IP by doing one of the following. IP is what you copied from your machine's hosts file by host.docker.internal
Docker argument:
--add-host="local.example.com:IP"
Docker compose:
extra_hosts:
- "local.example.com:IP"
Kubernetes:
hostAliases:
- ip: "IP"
hostnames:
- "local.example.com"
Problem is inside the container the opened port is 80 and docker is exposing 32795 for external connections
Wordpress configuration is pointing to port 32795, you might expose port 80 by doing docker run -p 80:80 and change wordpress configuration to use port 80
If you can't use port :80 a little bit more complicated solution is to use iptables port forwarding internally
Example
➜ ~ docker run -d --cap-add=NET_ADMIN --cap-add=NET_RAW -p 5000:80 nginx
835b039cc92bd9f32b960181bf370d39869c88f5a757423966b467fe01ac219e
➜ ~ docker exec -it 835b039cc92bd9 bash
root#835b039cc92b:/# apt update -qqq ; apt install iptables -yqqq
root#835b039cc92b:/# iptables -t nat -A OUTPUT -o lo -p tcp --dport 5000 -j REDIRECT --to-
port 80
root#835b039cc92b:/# apt install telnet -yqqq
root#835b039cc92b:/# telnet localhost 5000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
root#835b039cc92b:/# exit
# from outside the container
➜ ~ telnet localhost 5000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.

Nginx- error: bind() to 0.0.0.0:80 failed. permission denied

I am trying to run Nginx, but I am getting the error below:
bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a
socket in a way forbidden by its access permissions)
Please provide some help on what changes I need to do to make it working?
I have tried running on ports other than 80 and it works. but I need it to be running on 80.
Note: I am running on Windows 7 with command prompt running as Administrator.
If the port is already in use, you can change the default port of 80 to a different port that is not in use (maybe 8070). In conf\nginx.conf:
server {
listen 8070;
...
}
After startup, you should be able to hit localhost:8070.
tl;dr
netsh http add iplisten ipaddress=::
Faced similar issue. Run the above command in command prompt.
This should free up port 80, and you'd be able to run nginx.
Description:
netsh http commands are used to query and configure HTTP.sys settings and parameters.
add iplisten :
Adds a new IP address to the IP listen list, excluding the port number.
"::" means any IPv6 address.
For more netsh http commands refer the netsh http commands documentation.
Hope this helps!!
You have to be admin or root to bind port 80. Something you can do if you cannot run as root, is that your application listens to other port, like 8080, and then you redirect messages directed to 80 to 8080. If you are using Linux you redirect messages with iptables.
nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
I got a similar problem, My 80 port was listening to IIS (windows machine). Stopping IIS freed up 80 port.
The problem got resolved...!!
Please check if another Proxy is running under port 80 ---> in my case IIS was running as a reverse proxy, so nginx could not start..
Stopping IIS, and starting of NGXIN solved the problem
My Tomcat server was running on port 80. Changed the port number in conf\nginx.conf file and it started to work.
This is an old question but since I had this problem recently I thought of posting another possible reason in this problem.
If the user is using Docker and has already tried all proposed solutions as stated above and is wondering why port 80 is trying to bind although on your configurations you are overwriting the port to non root port e.g. listen 8080; it seems that the newer NGINX images have a default nginx.conf file in /etc/nginx/conf.d.
Sample:
$ grep -r 80 /etc/nginx/
/etc/nginx/conf.d/default.conf: listen 80;
On my case I removed it on my Dockerfile:
RUN set -x \
&& rm -f /etc/nginx/nginx.conf \
&& rm -f /etc/nginx/conf.d/default.conf
Next step pass from my custom configurations:
COPY ["conf/nginx.conf", "/etc/nginx/nginx.conf"]

Docker - port prevents listening

I am trying to setup xdebug integration on my docker-based setup.
I am using Docker for Mac 1.12.0-rc2-beta17 with the "native" docker machine
I have a container, with xdebug installed, exposing port 9000 and mapping it to the port 9000:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6950c2a2b05d app "/usr/bin/supervisord" 9 minutes ago Up 9 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:9000->9000/tcp, 0.0.0.0:2222->22/tcp app_1
When I'm trying to use PhpStorm to listen to the port 9000 for debug connections, I'm getting an error "Cannot listen: port 9000 is busy".
I must precise that I'm a newbie in networks..
It dependent how you want to connect via Xdebug
xdebug.remote_connect_back=1 said that PHP will wait until a HTTP request with GET parameter XDEBUG_SESSION_START=<IDE_key>. Then will PHP within the server try to connect back via port 9000 where your PHPStorm is listing. Classic don't call us, we will call you situation.
Now your situation with docker say simple, your container is responsible for port 9000. So PHP will get a loopback and PHPStorm isn't able to use port 9000 because its already used by your docker container.
So skip the assignment of port 9000 to docker, that will fix this situation.
You must bind 9000 port with --expose option.
This is the reference
if you are using docker compose sample docker-compose.yml file is here:
version: '2'
services:
your_app:
ports:
- "80:80"
expose:
- "9000"
image: "your-image:tag"
Firstly check your container logs to debug:
docker logs 6950c2a2b05d
or
docker logs app_1
Add -f flags for tail-like behavior:
docker logs -f app_1
Two things I discovered:
There is no need to expose the port 9000 on a container with xdebug (that seems rather counter-intuitive for me, as I do not exactly understand how my IDE connects to xdebug then).
I was able to use xdebug using the workaround described in https://forums.docker.com/t/ip-address-for-xdebug/10460/4.

Kibana4 to listen on Port 80 instead of Port 5601

I have elasticsearch 1.4 and kibana4 running on an Amazo EC2 instance running RHEL7.
Kibana4 is running as a standalone process and is not deployed in a web container such as nginx.It is listening on Port 5601.(the default port). I would like to have kibana listen on port 80.
Can this be achieved without using nginx? If yes how?
You need to set capabilities CAP_NET_BIND_SERVICE to bind non root process to a privileged port (<1024)
to make kibana listen on port 80 :
1- edit kibana port in /etc/kibana/kibana.yml
server.port : "80"
2- run the following commands :
sudo setcap cap_net_bind_service=+epi /usr/share/kibana/bin/kibana
sudo setcap cap_net_bind_service=+epi /usr/share/kibana/bin/kibana-plugin
sudo setcap cap_net_bind_service=+epi /usr/share/kibana/bin/kibana-keystore
sudo setcap cap_net_bind_service=+epi /usr/share/kibana/node/bin/node
Edit file {kibana-directory}/config/kibana.yml. Find this line:
port: 5601
and change it to:
port: 80
Setting the port 80 in config file will trigger the following error
kibana[11777]: FATAL Error: listen EACCES: permission denied 0.0.0.0:80
due to the fact that kibana service by default executes under the user kibana
You can change the user to root, but this will trigger the following warning
kibana[11639]: Kibana should not be run as root. Use --allow-root to continue.
So running kibana service under root user is something not recommended. Better make a port forwarding rule, or a HTTP redirect if you have a web server.
Full settings here: https://www.elastic.co/guide/en/kibana/current/settings.html
This should be added to config/kibana.yml
server.port: 80
And run kibana server with sudo. Make sure no process is using port 80 at the same time.

Cannot assign requested address: make_sock: could not bind to address

Previously my IP was 10.0.6.63 , the apache server was working fine.
On reboot DHCP changed my IP address to 10.0.15.12 Now when i try to start apache it is giving me following error
$service httpd restart
Starting httpd: [Fri Jan 11 16:17:28 2013] [warn] module wsgi_module is already loaded, skipping
(99)Cannot assign requested address: make_sock: could not bind to address 10.0.6.63:80
no listening sockets available, shutting down
Unable to open logs
If you are working with a moving IP address do no use IP based virtualhosts but named based virtulahosts.
Check this apache documentation link
Solved: Sorry guys, mistake. I had another configuration in /etc which was overriding the local configuration . which was configured for old ip.
I think you can check httpd.conf(default config file name) config file.
#Listen 12.34.56.78:80
you can change you server ip address .
I had a similar problem.
I resolved it by disabling or commenting out
this line Listen 192.168.1.80:80 in /etc/httpd/conf.d/ssl.conf.
I am running Virtualmin on a Centos 5.11
In the /etc/httpd/conf.d/ssl.conf file:
#LoadModule ssl_module modules/mod_ssl.so
#Listen 443
Comment out these lines
I was facing similar problem with apache but when i checked , I got that, the particular IP address on which my server is trying to bind is not there as that interface was deleted when my machine was rebooted.
I did following :
run dhclient to get the interface and IP
given command to create the sub interface which I had created for my apache server to listen : ifconfig ens6:1 10.10.0.80/16 up

Resources