Address already in use for puma-dev - ruby-on-rails-5

Problem
Whenever I try to run
bundle exec puma -C config/puma.rb --port 5000
I keep getting
bundler: failed to load command: puma (/Users/ogirginc/.asdf/installs/ruby/2.7.2/bin/puma)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 5000
Tried Things
I have tried anything I can think of or read. Here is the list:
1. Good old restart the mac.
Nope.
2. Find PID and kill.
Run lsof -wni tcp:5000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ControlCe 6071 ogirginc 20u IPv4 0x1deaf49fde14659 0t0 TCP *:commplex-main (LISTEN)
ControlCe 6071 ogirginc 21u IPv6 0x1deaf49ec4c9741 0t0 TCP *:commplex-main (LISTEN)
Kill with sudo kill -9 6071.
When I kill it, it is restarted with a new PID.
> lsof -wni tcp:5000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ControlCe 6071 ogirginc 20u IPv4 0x1deaf49fde14659 0t0 TCP *:commplex-main (LISTEN)
ControlCe 6071 ogirginc 21u IPv6 0x1deaf49ec4c9741 0t0 TCP *:commplex-main (LISTEN)
3. Use HTOP to find & kill
Filter with puma.
Found a match.
PID USER PRI NI VIRT RES S CPU% MEM% TIME+ Command
661 ogirginc 17 0 390G 6704 ? 0.0 0.0 0:00.00 /opt/homebrew/bin/puma-dev -launchd -dir ~/.puma-dev -d localhost -timeout 15m0s -no-serve-public-paths
Kill it with sudo kill -9 661.
Restarted with a new PID.
Additional Info
rails version is 5.2.6.
puma version is 4.3.8.
puma-dev version is 0.16.2.
Here are the logs for puma-dev:
2021/10/26 09:48:14 Existing valid puma-dev CA keypair found. Assuming previously trusted.
* Directory for apps: /Users/ogirginc/.puma-dev
* Domains: localhost
* DNS Server port: 9253
* HTTP Server port: inherited from launchd
* HTTPS Server port: inherited from launchd
! Puma dev running...
It feels like I am missing something obvious. Probably, due to lack of understanding some critical & lower parts of puma-dev. I would really appreciate, if this is solved with some simple explanation. Thanks in advance! :)

Why
Well, this is interesting. I did not think of searching for lsof's COMMAND column, before.
Turns out, ControlCe means "Control Center" and beginning with Monterey, macOS does listen ports 5000 & 7000 on default.
Solution
Go to System Preferences > Sharing
Uncheck AirPlay Receiver.
Now, you should be able to restart puma as usual.
Source: https://developer.apple.com/forums/thread/682332

Related

Apache Superset not available from my browser

After following the installation instructions referenced at https://superset.apache.org/docs/installation/installing-superset-from-scratch, I'm not able to see the app at the ip number/server port in my win 10 web browser. How do I make it work at the right ip address?
I've installed it under venv running on a CentOS 8 VM on my win 10 laptop. I'm using the NAT network adapter and I can can use putty and the CentOS 8 cockpit app is available on port 9090.
Currently it says it's running at 127.0.0.1:8089:
(venv) /root>superset run -p 8089 --with-threads --reload --debugger
logging was configured successfully
2021-08-04 15:35:48,492:INFO:superset.utils.logging_configurator:logging was configured successfully
2021-08-04 15:35:48,505:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
/root/venv/lib64/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
warnings.warn(
No PIL installation found
2021-08-04 15:35:48,722:INFO:superset.utils.screenshots:No PIL installation found
* Serving Flask app "superset" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
2021-08-04 15:35:50,007:INFO:werkzeug: * Running on http://127.0.0.1:8089/ (Press CTRL+C to quit)
netstat shows port 8089 open for 127.0.0.1, but not the VM's ip number. nmap shows the port closed.
/root>netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 944/sshd
tcp 0 0 127.0.0.1:8089 0.0.0.0:* LISTEN 4247/python3
tcp6 0 0 :::9090 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 944/sshd
/root>nmap 192.168.42.130
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-04 15:45 PDT
Nmap scan report for kevinsAppServer (192.168.42.130)
Host is up (0.000015s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
9090/tcp open zeus-admin
Nmap done: 1 IP address (1 host up) scanned in 1.73 seconds
/root>nmap -p 8089 192.168.42.130
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-04 15:45 PDT
Nmap scan report for kevinsAppServer (192.168.42.130)
Host is up (0.000067s latency).
PORT STATE SERVICE
8089/tcp closed unknown
I think it should work if i can get the port opened on my server's IP number, unless there's something I did wrong..
I got it to work by adding the -h option for the superset run command, which I found when running the superset run --help at the server command line. So now this command works:
superset run -h my.i.p.adddress -p 8089 --with-threads --reload --debugger
In my case I also had to open port 8089 on the CentOS firewall.

Mac cant kill tomcat process

I can't stop the tomcat8 in IDEA, even I use 'kill process' button , it can't works. Who can help me?
enter image description here
My IDEA's version is 2017.2.5.
I usually run this: lsof -n -i4TCP:$PORT | grep LISTEN from command line
Where I replace $port with 8080 for example.
Example output:
java 20561 pim 80u IPv6 0x85f7db71b181d26b 0t0 TCP *:8080 (LISTEN)
And then kill the process manually (the PID is 20561 in this example) with:
kill -9 20561

How to enable SSH on SLES 12?

I am trying to enable ssh connection to suse linux. I have sshd service running:
peeyush#linux-pohb:~/gccgo.work> systemctl status sshd.service
sshd.service - OpenSSH Daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since Thu 2015-03-19 18:36:05 IST; 3h 50min ago
Process: 5702 ExecStartPre=/usr/sbin/sshd-gen-keys-start (code=exited, status=0/SUCCESS)
Main PID: 6035 (sshd)
CGroup: /system.slice/sshd.service
└─6035 /usr/sbin/sshd -D
Mar 19 18:36:01 linux-pohb sshd-gen-keys-start[5702]: Checking for missing se...
Mar 19 18:36:05 linux-pohb sshd-gen-keys-start[5702]: ssh-keygen: generating ...
Mar 19 18:36:06 linux-pohb sshd[6035]: Server listening on 0.0.0.0 port 22.
Mar 19 18:36:06 linux-pohb sshd[6035]: Server listening on :: port 22.
Hint: Some lines were ellipsized, use -l to show in full.
It is listening on port 22 fine:
peeyush#linux-pohb:~/gccgo.work> netstat -an | grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
But I am not able to connect to it.
[root#lep8a peeyush]# ssh root#192.168.122.19
ssh: connect to host 192.168.122.19 port 22: Connection timed out
My head is aching with finding solutions on internet. Nothing is working.
Could you guys please help me out?
Check if your firewall accepts incoming TCP connections on port 22:
# iptables -nL | grep 22
If the result is empty, you have to add a rule in your firewall.
Open Yast and firewall configuration:
# yast firewall
Goto "Allowed Services" and add "Secure Shell Server". Save and quit Yast and try to connect.
Comment: If you have disabled your firewall completly (not recommended) this answer does not apply.
Run this command:
systemctl enable sshd.service
Then make necessary changes in your /etc/ssh/sshd_config file, and start sshd via:
systemctl start sshd.service
I was dealing with the same problem in SUSE Linux Enterprise Server 15 x86-64. Within the system I was able to # ssh 127.0.0.1 (so the sshd service was working correctly), but from other nodes I got a "Timed out" message.
First, I checked the firewall rules (see answer from xloto):
# iptables -nL | grep 22
Resulted in an empty return message, so we need to set an additional rule.
To set the the firewall rule for SSH's standard port 22, I followed another tutorial (as I do not have a GUI):
# firewall-cmd --permanent --add-service=ssh
# firewall-cmd --reload
It worked for my case, but I'm not sure whether this is best practice.

Running Reactive Native Project giving 404 not found

Running react-native sample project gives me a
404 Not Found. The Server could not locate the resource you request.
This can also happen if you've got an existing service running on port 8081, since that's the port that the packager runs on.
OPTION 1
Load from development server. Start the server from the repository root:
$ npm start
To run on device, change localhost to the IP address of your computer, and make sure your computer and iOS device are on the same Wi-Fi network.
just like this:
jsCodeLocation = [NSURL URLWithString:#"http://192.168.8.190:8081/Examples/2048/Game2048.includeRequire.runModule.bundle"];
To expand on Colin Ramsay's answer, you can check if a service is running on port 8081 by running the following command on OSX:
lsof -i :8081
If anything is running, something like his will show:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 918 Robert 6u IPv4 0x5c8c06c2a2e769cf 0t0 TCP *:sunproxyadmin (LISTEN)
nginx 1010 Robert 6u IPv4 0x5c8c06c2a2e769cf 0t0 TCP *:sunproxyadmin (LISTEN)
You can then use the PID to kill that service:
kill -9 918

'ubd' Process interfering with MAMP at port 80 [duplicate]

This question already has answers here:
How do I find out how macPorts stole my port:80?
(6 answers)
Closed 3 years ago.
A few days ago my Apache server stopped 'starting'. Does anyone know about this problem.
I believe it is happening now because I, stupidly, moved a file called index.php into the htdocs/ folder.
I run lsof -i | grep LISTEN to get:
mysqld 297 waltercarvalho 10u IPv4 0xc942753e30142a85 0t0 TCP *:mysql (LISTEN)
ubd 611 waltercarvalho 18u IPv4 0xc942753e310c9f35 0t0 TCP *:49228 (LISTEN)
ubd 611 waltercarvalho 19u IPv6 0xc942753e2d7a5635 0t0 TCP *:49228 (LISTEN)
Dropbox 720 waltercarvalho 18u IPv4 0xc942753e310c90c5 0t0 TCP *:17500 (LISTEN)
Dropbox 720 waltercarvalho 25u IPv4 0xc942753e31c584dd 0t0 TCP localhost:26164 (LISTEN)
When I try to start the Apache server on port 80, in order to access localhost (the clean way), I get:
I run sudo /Applications/MAMP/bin/startApache.sh to get:
(48)Address already in use: make_sock: could not bind to address [::]:80
(48)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Which means port 80 is being used. You can find my httpd.conf file at:
http://pastebin.com/dta3hND8
I have been trying to fix this for a few hours now, extremely frustrating. I have tried everything.
Thank you.
i've been struggling with this issue.. fairly certain it's dropbox that's interfering. i found a solution that works like a charm, albeit not a perm fix. i run the sequence fairly often. it's an annoyance, but at least these steps are clear, simple, and predictable! ..AND i get my 80/3306 back.
fix courtesy of Abhinav Sood.
Launch MAMP. Open Terminal by typing terminal into Spotlight (Command + Space).
Open MAMP Preferences (Command + , ) and click on Reset MAMP Ports
(Port 8888 and Port 8889 for Apache and MySQL respectively).
Click on OK.
Switch to the terminal. Type sudo apachectl stop to shutdown the system Apache.
Restart MAMP.
Open MAMP Preferences once again and click on Set to Default Apache and MySQL ports. This will set the Apache and MySQL ports to 80 and 3306 respectively.
Switch to the terminal. Type sudo apachectl restart to restart Apache.
Switch back to MAMP and click on Open Start Page (or go to http://localhost/MAMP/?language=English in your browser)
And you’re done.