I am having issues with setting up Laravel Valet on my machine (MacOS Mojave 10.14). I followed the official documentation on Laravel documentation site. I have installed Valet, added Composer to path, I can run valet and laravel commands from anywhere in the system so that works. I have mapped my project folder with valet park. I can also do a ping on any *.test domain and it returns 127.0.0.1 responses.
I have created a new project laravel new blog within that directory and when accessing http://blog.test I am getting nginx 403 forbidden response.
I suspect something may conflict maybe so I tried these steps, none of which worked:
Added explicitly both blog and blog/public to valet link blog and valet link blog2. Accessing blog.test and blog2.test both return forbidden
Killing Apache with sudo apachectl stop returns:
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
sudo killall httpd returns:
No matching processes were found
Uninstalling nginx and running valet install again didn't help.
Running sudo nginx returns:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()
NOTE: I do have a Docker running on my machine
I have found Docker to be the issue. I already had an app running on port 80 so it was preventing nginx from starting. I shut down the container and run sudo nginx and it solved the issue.
Related
Having a terribly frustrating time not having valet working on a fresh install. Going to any *.test site in my browser just hangs and eventually gets the error message This site can’t be reached, "ping app.test" hangs as well, and eventually errors with "ping: cannot resolve app.test: Unknown host". However pinging a different domain (such as ping.xyz errors immediately, as opposed to after ~20 seconds like with *.test).
On Os Sierra, my composer.json looks like the following
{
"require": {
"laravel/installer": "^1.5",
"laravel/valet": "dev-master"
}
}
Since I've seen that dev-master resolved this for some people. All my processes seem to be running:
However some clues are that http://localhost/ in my browser returns a page 404 - not found, and running sudo nginx returns a bunch of already in user errors:
❯ pwd
/Users/schorr/.valet
schorr#Andrew-Schorr ~/.valet
❯ sudo Nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
and valet fetch-share-url returns
❯ valet fetch-share-url [17:04:53]
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
...
Any help is greatly appreciated. thanks!
Finally figured this out, for anyone else in my very specific situation:
I had changed my user name on the same machine, and for whatever reason installing dnsmasq wasn't overwriting the old /Users/user/.valet/dnsmasq.conf file. So at the very bottom I had:
conf-file=/Users/OLD_USER_NAME/.valet/dnsmasq.conf
conf-file=/Users/NEW_USER_NAME/.valet/dnsmasq.conf
So all I had to do was comment out the OLD_USER_NAME line and was good to go :|
Append http:// to the url the first time you hit it. For example use http://websitedir.test
I hope it's this simple, let me know.
Try the command 'valet paths' and let me know what that spits out.
I'm trying to connect my port 7979 to nginx and it doesn't work.
I was on localhost:7979/myproject/app/index.php but when I restarted my mac and I updated it, I now see the error message:
ERR_CONNECTION_REFUSED
When I try sudo nginx I see the following messages.
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()
Port 80 is functioning. If I go to localhost:80 I see this message in the html page:
Default website Congratulations, your Nginx seems to work just fine.
:)
Why am I unable to use port 7979?
I changed the root and the port and it worked on site-available/default.
The root by default wasn't good i don't know why it changed when i restarted my mac.
THan
It's difficult to troubleshoot with this little info available. So first:
An error message like nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) indicates that something is already listening on port 80 and hence nginx can't do that as well when you start it.
Assuming your configuration files are perfectly ok, you'll have to figure out what is already listening on ports 80, 443 and 306. It might be an instance of nginx that's running with an older configuration but without much more details thats' just a guess.
See what processes are running:
$ ps -ax
See if there's an nginx instance running:
$ ps -ax | grep nginx
Netstat can give you what ports are being listened to:
$ nestat -an | grep LISTEN
To find out which process is listening to a given port:
$ sudo lsof -i :631
(631 is just an example)
What I suspect: you're starting nginx while it's already running. If it's already running, you should restart it instead of starting a new copy.
This might be of help: https://serverfault.com/questions/225948/how-to-restart-nginx-on-mac-os-x
In essence:
$ sudo nginx -s reload
Just a warning I don't run nginx on macOS, but it should work if nginx on macOS reacts like it does on FreeBSD (which macOS uses as a long distant base)
I have downloaded PhpStorm and set all the required configuration. When I try to run the project on port 80, I get this error.
Failed to listen on localhost:80 (reason: Permission denied)
And when I try to use any other ports like 8080 ,I get this error.
Failed to listen on localhost:8080 (reason: Address already in use)
I have tried several different random ports. But I get this already in use error all the time.
I have xampp installed. And when I try to run the url in browser with port , it works fine. The problem is that it isn't working on PhpStorm.
I am stuck.
The errors description are very clear:
The error:
Failed to listen on localhost:80 (reason: Permission denied)
You really don't have permission to use this port; so you need to change your user or use sudo to run your application.
and the error:
Failed to listen on localhost:8080 (reason: Address already in use)
The address that you are trying to use localhost:8080 is already in use by other processes/software.
Normally, if you change the port will solve the problem: (eg. 9090).
But, if you want to know which program is using the port 80 in Unix (Mac OSX, Linux), you can use the lsof command:
To do this:
In the terminal, you need to use:
sudo lsof -i :80
That will result something like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 82 root 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN)
httpd 226 _www 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN)
On this result, we can see that the /usr/sbin/httpd is listening on port 80 on my machine, which is the Apache server.
To know the details of the process that is listening on port 80 you can use the ps command:
ps u PID_of_target_process
that will return a result similar to this:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 82 0.0 0.0 2463324 4248 ?? Ss 9:48AM 0:00.93 /usr/sbin/httpd -D FOREGROUND
To kill the process by the PID you can use the kill command, like the following:
sudo kill -KILL PID_of_target_process
After you kill the process the port will be available again.
The PHPStorm / Intellij built-in web server listens on port 63342 by default.
https://confluence.jetbrains.com/display/PhpStorm/Using+the+Built-in+Webserver+in+PhpStorm
You can set the port in the Run/Debug Configurations under PHP Built-in Web Server:
Stop your Apache server from XAMPP.
Run your PHPStorm with ROOT privileges.
If running PHPStorm is showing your the same error saying Failed to listen on localhost:8080 (reason: Address already in use). The ports 80 is used by any other application. Try checking your used ports with a free tools out there. Stop the process using port 80 and try running the phpstorm.
Xampp for Mac
if you find you cannot get apache to run and you have
no apache web server already running!
......in terminal type.....
sudo apachectl stop
......then run......
sudo /Applications/XAMPP/xamppfiles/bin/apachectl start
.....if you have a port not specified you need to go into
applications/xampp/xamppfiles/etc/httpd.conf and on line 52 or 53
you have a ip or localhost you can set.
adding a port number
add :port number example 192.168.64.2:80 or localhost:80
save and run sudo /Applications/XAMPP/xamppfiles/bin/apachectl start }}}}}}}}}}}}}
I recently migrated to Mac OSX Yosemite 10.10 and I followed this tutorial.
To set up my machine, After a lots of hiccups I finally managed to reach a point where I find just a single issue happening due to nginx port issues.
If I do
sudo nginx
I get this
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()
which means 443 and 306 ports are being used somewhere else
and when I do
sudo lsof -i:443
I get this
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)
nginx 549 nobody 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)
similarly for sudo lsof -i:306
I get
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)
nginx 549 nobody 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)
Now if nginx is already using these ports, how come it is claiming that Address is already in use
and when I run my app in browser say abc.dev.com
I get no response from server, after sometime browser simply tells me
The connection has timed out
The server at abc.dev.com is taking too long to respond.
If i do curl http://abc.dev.com I get
curl: (7) Failed to connect to abc.dev.com port 80: Operation timed out
Also If I do
nginx.start
I get this:
/Library/LaunchDaemons/homebrew.mxcl.nginx.plist: Operation already in progress
if I do::
nginx.stop //it works, I think it stops
if I do:
nginx.restart
I get this:
/Library/LaunchDaemons/homebrew.mxcl.nginx.plist: Could not find specified service
I have ran out of ideas and can't think of anything that could be causing this. Any Ideas are highly appreciated...
Thanks for the help.
Author of the guide you've linked above here. It seems like you managed to get Nginx running without the proper LaunchDaemon.
Can you make sure, when you enter "nginx.stop", the process is really stopped? (ps aux).
Regarding the last error while "nginx.restart": thats normal, because you already stopped the service before with "nginx.stop". So a restart (actually: stop && start) will come up with the error since it's trying to stop an already stopped service.
Anyway, since your issue is pretty much guide-dependent / relevant, I'm not sure if StackOverflow is the right place for this discussion. Let's better continue in the comment section of the guide.
I installed PHPMyAdmin via apt-get on my Ubuntu and I set the directory in apache2.conf, but when starting the server, nothing happens when http://127.0.0.1/phpmyadmin access and the following message appears I my console:
juninho-desktop:~$ /etc/init.d/apache2 restart
* Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
This is my /etc/apache2/apache2.conf file:
http://pastebin.com/yafW00S6
you could type:
netstat -lnptu
in your terminal. Then look for a programm that is blocking the Port 80.
This programm needs to be closed or must use another port :)
Permission problems, try to restart apache2 using root priviliges:
sudo /etc/init.d/apache2 restart