redis-server not working if port is changed - php

sudo systemctl status redis-server.service
its ok
redis active en other port example 30000
but
redis-server --port 30000
oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5315:C 24 Aug 00:07:42.719 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=5315, just started
5315:C 24 Aug 00:07:42.719 # Configuration loaded
5315:M 24 Aug 00:07:42.720 # Creating Server TCP listening socket *:30000: bind: Address already in use
use
ps aux | grep redis
and them kill -9 process
and then
redis-server --port 30000
but iqual

Check port 30000 is not blocked by your firewall. If your redis is start on cloud, check port 30000 is added in your security group.

Related

I tried to start laravel project on linux

Suddenly... my website happens timeout-error.
it seems not process does not work.
How should I restart the project...
php-fpm.conf
$ service apache2 restart
Redirecting to /bin/systemctl restart apache2.service
Failed to restart apache2.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status apache2.service' for details.
[ec2-user#ip-172-31-30-200 laravel6]$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: failed (Result: exit-code) since Mon 2021-04-12 09:12:06 ; 1min 48s ago
Docs: man:httpd.service(8)
Process: 4123 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 4123 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."
.ap-northeast-1.compute.internal systemd[1]: Starting The Apache HTTP Server...
.ap-northeast-1.compute.internal httpd[4123]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
.ap-northeast-1.compute.internal httpd[4123]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
.ap-northeast-1.compute.internal httpd[4123]: no listening sockets available, shutting down
.ap-northeast-1.compute.internal httpd[4123]: AH00015: Unable to open logs
.ap-northeast-1.compute.internal systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
.ap-northeast-1.compute.internal systemd[1]: Failed to start The Apache HTTP Server.
.ap-northeast-1.compute.internal systemd[1]: Unit httpd.service entered failed state.
.ap-northeast-1.compute.internal systemd[1]: httpd.service failed.
$ systemctl restart php7.0-fpm.service
Failed to restart php7.0-fpm.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status php7.0-fpm.service' for details.
$ systemctl stop httpd
Failed to stop httpd.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status httpd.service' for details.
#nuzil answer here,
48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Please edit httpd.conf file.
/usr/local/etc/httpd/httpd.conf
And replace
Listen 80
with
Listen 127.0.0.1:80
Restart apache
sudo apachectl -k restart
Maybe you tried use same port in two configuration files, or 80 port used on other service like nginx. Try sudo lsof -n -i :80 | grep LISTEN to check process that using 80 port.
Also, you missed the sudo command to execute systemctl command. Maybe that is permission problem.

Why PHP-FPM socket stops allowing connections from Docker after restart?

PHP-FPM is running locally on my Ubuntu 20.04 installation, configured to listen on a socket:
/etc/php/7.4/fpm/pool.d/www.conf:
[www]
user = www-data
group = www-data
listen = /run/php/php7.4-fpm.sock
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
;listen.acl_users =
;listen.acl_groups =
I can start a Docker container and communicate with PHP-FPM by sharing the socket file through a bind mount volume:
$ docker run --rm -it \
-v "/etc/passwd:/etc/passwd:ro" \
-v "/etc/group:/etc/group:ro" \
-v "/run/php/php7.4-fpm.sock:/run/php-fpm/www.sock" \
alpine:latest
/ # apk add --no-cache fcgi
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/1) Installing fcgi (2.4.2-r0)
Executing busybox-1.31.1-r16.trigger
OK: 6 MiB in 15 packages
/ # ls -lah /run/php-fpm/www.sock
srw-rw---- 1 www-data www-data 0 Oct 30 21:25 /run/php-fpm/www.sock
/ # REQUEST_METHOD=GET SCRIPT_FILENAME=index.php cgi-fcgi -bind -connect /run/php-fpm/www.sock
Primary script unknownStatus: 404 Not Found
Content-type: text/html; charset=UTF-8
File not found.
Now if I restart PHP-FPM on the host while the container is still running:
$ sudo systemctl restart php7.4-fpm.service
$ sudo tail -n 6 /var/log/php7.4-fpm.log
[30-Oct-2020 18:25:36] NOTICE: systemd monitor interval set to 10000ms
[30-Oct-2020 18:28:47] NOTICE: Terminating ...
[30-Oct-2020 18:28:47] NOTICE: exiting, bye-bye!
[30-Oct-2020 18:28:47] NOTICE: fpm is running, pid 67860
[30-Oct-2020 18:28:47] NOTICE: ready to handle connections
[30-Oct-2020 18:28:47] NOTICE: systemd monitor interval set to 10000ms
I am no longer able to connect to the socket from the Docker container:
/ # REQUEST_METHOD=GET SCRIPT_FILENAME=index.php cgi-fcgi -bind -connect /run/php-fpm/www.sock
Could not connect to /run/php-fpm/www.sock
If the container is re-started, it works again.
So I imagine that the problem is related to how sockets shared in bind mounts work, but it could also be on PHP-FPM, I have no idea on how to "fix" this.

MySQL ERROR 2002 (HY000): Can't connect to local MySQL server through socket

I noticed this issue when my Wordpress server started throwing aa MySQL error. To try to debug Wordpress, I attempted to connect manually.
I get the following:
$ mysql -u root -p -h localhost -P 3306
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/bitnami/mysql/tmp/mysql.sock' (2)
I've also tried no -h option and 127.0.0.1
It looks like MySQL is running.
$ ps -ef | grep mysql
mysql 14743 1 0 15:20 ? 00:00:00 /usr/sbin/mysqld
bitnami 14939 13882 0 15:28 pts/0 00:00:00 grep --color=auto
mysql-server is installed, but /opt/bitnami/mysql/tmp/mysql.sock does not exist.
It looks like MySQL is listening on the correct port.
$ telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
[
5.5.54-0ubuntu0.14.04.1,IIq{;Rh�k>5/)"m"[&J#mysql_native_password
!#08S01Got packets out of orderConnection closed by foreign host.
Following the suggestion here:
$ sudo /opt/bitnami/ctlscript.sh status
php-fpm already running
apache already running
mysql not running
$ sudo /opt/bitnami/ctlscript.sh start mysql
2017-02-14T16:53:25.064586Z mysqld_safe Logging to '/opt/bitnami/mysql/data/mysqld.log'.
2017-02-14T16:53:25.233250Z mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
2017-02-14T16:53:28.400598Z mysqld_safe mysqld from pid file /opt/bitnami/mysql/data/mysqld.pid ended
/opt/bitnami/mysql/scripts/ctl.sh : mysql could not be started
Monitored mysql
Here are a few choice lines from /opt/bitnami/mysql/data/mysqld.log. It looks like theres a conflict.
2017-02-14T17:03:31.274720Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2017-02-14T17:03:31.274778Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2017-02-14T17:03:31.274835Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2017-02-14T17:03:31.274888Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2017-02-14T17:03:31.274901Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2017-02-14T17:03:31.274952Z 0 [ERROR] Aborting
The issue is that you already have a mysql server running which is not the bitnami one. You should stop that service first before start the mysql server from bitnami.
You can try to stop with:
$ sudo service mysql stop
If it doesn't work you can kill the process:
$ sudo kill 14743
And finally start the bitnami mysql server with this command:
$ sudo /opt/bitnami/ctlscript.sh start mysql
After this server is running you should be able to connect without problems.
Before doing anything first check space. Make sure it is not used 100%
df -h
If space is available.
For Chcecking Mysql is running or not.
ps xufa | grep mysql
Restart mysql
sudo service bitnami restart mysql

OSX: Failed to listen on localhost:80 (reason: Permission denied)

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 }}}}}}}}}}}}}

Unable to start laravel development server on linux

I am using laravel 5 for my project and everything has been working fine but recently I am facing this problem which I done understand.
devboy#devboy-hp ~/sonel_ims_project/ims_eneo $ php artisan serve
Laravel development server started on http://localhost:8000/
[Fri Nov 13 12:00:56 2015] Failed to listen on localhost:8000 (reason: Address already in use)
I have tried devboy#devboy-hp ~ $ sudo netstat -plnt and get
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1840/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1985/cupsd
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 7563/php-5.6.3
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1656/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 6966/httpd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 7442/java
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 6931/php-5.6.3
tcp 0 0 0.0.0.0:6667 0.0.0.0:* LISTEN 1539/ircd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 7442/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6966/httpd
tcp6 0 0 :::21 :::* LISTEN 7337/proftpd: (acce
tcp6 0 0 ::1:631 :::* LISTEN 1985/cupsd
tcp6 0 0 :::3128 :::* LISTEN 1416/squid3
tcp6 0 0 :::25 :::* LISTEN 1656/master
tcp6 0 0 :::445 :::* LISTEN 740/smbd
tcp6 0 0 :::3306 :::* LISTEN 7343/mysqld
tcp6 0 0 :::139 :::* LISTEN 740/smbd
Then I change port like so php artisan serve --port="8888"
but get similar error like below after a while:
Laravel development server started on http://localhost:8888/
[Fri Nov 13 12:01:02 2015] Failed to listen on localhost:8888 (reason: Address already in use)
The first time it happened, it was java using port 8000, so I killed the process and started the server and it worked. Upon stopping and restarting, I get the same error. What could be the problem (as I said everything has been working fine except now and I have not done any major update)?
Your previous deployment in your local is already running that's why you can't run php artisan serve. You can solve your issue by following this command in your terminal:
ps -ef | grep php you'll see this list:
gujarat 6690 3500 0 05:55 pts/1 00:00:00 php artisan serve
gujarat 6694 6690 0 05:55 pts/1 00:00:00 sh -c '/usr/bin/php5'
-S localhost:8000 '/home/gujarat/WebDevelopment/quickstart-basic'/server.php gujarat 6695 6694 0 05:55 pts/1 00:00:00 /usr/bin/php5 -S localhost:8000
/home/gujarat/WebDevelopment/quickstart-basic/server.php
gujarat 7436 3500 0 06:26 pts/1 00:00:00 grep --color=auto php
Now kill it using: sudo kill 6690 if still exist then use this sudo kill -9 6690 you'll see this result:
[1]+ Killed php artisan serve
Now you can serve your local using php artisan serve again
please restart apache server
sudo apache restart
And once again run your project in another port
php artisan serve --port=2020
This is exactly what I did for the problem.
I exit PHPStorm
sudo netstat -plnt
kill 7563 (Process using port 8888)
kill 6931 (Process using port 8000)
sudo /opt/lampp/lampp restart (Restart my server altogther)
php artisan serve
Launch PhpStorm
Now everything is working fine. What caused the problem anyway?
Using lsof, you can see what is listening on the port.
sudo lsof -i :80
Change the 80 to whichever port you're interested. You need to be root or sudo.
Run this comment
sudo netstat -plnt
The output will show like this
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 14 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3648/php7.3
Then kill the port:8000 using this comment
kill -9 3648
Well the problem might be it didnt stop the expected way previously eg via CTRL+C so what you can do is to check for running php processes and kill them 1 by 1.
i) Run ps -A from the terminal then identify the php process ids (most of the times they are two)
ii) Run sudo kill -9 pid# corresponding to the php pids.
iii) Run php artisan serve and it will work.
This can happen when there is already an app running on 127.0.0.1:8000
You can close that app then it will work or not available on the current host.
OR if you want to run multple apps then use shown below way:
You can use this command to run sudo php artisan serve --port=8082 for Linux
php artisan serve --port=8082 for window

Categories