7

the lsof command tells me launchd is listening on port 4444:

$ sudo lsof -i tcp:4444

COMMAND PID USER   FD   TYPE           DEVICE SIZE/OFF NODE NAME
launchd   1 root   32u  IPv4 0xfe4e7e9bb5c1a5      0t0  TCP localhost:krb524 (LISTEN)
launchd   1 root   46u  IPv4 0xfe4e7e9bb5c1a5      0t0  TCP localhost:krb524 (LISTEN)

I'm trying to set up a Selenium (https://www.seleniumhq.org/) Server whose default port is 4444 - I realise I could change Selenium's port, but I don't recall having this clash on Macs previously (I guess prior to Tiger)

Is it possible/viable to have launchd run on a different port?

EDIT: I found the following info by searching which plist files refer to port 4444 - it shows that it's part of the Server configuration. The Wiki feature of Server is currently turned OFF. Is it safe to edit this file to change the port setting?

/Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.auth.plist:19: http://localhost:4444/auth /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.changepassword.plist:19: http://localhost:4444/changepassword /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.collabd.plist:24: http://localhost:4444/svc /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.collabd.plist:33: http://localhost:4444/streams/activity /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.wiki.plist:24: http://localhost:4444/preview /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.wiki.plist:33: http://localhost:4444/files /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.wiki.plist:42: http://localhost:4444/upload_file /Applications/Server.app/Contents/ServerRoot/private/etc/apache2/webapps/com.apple.webapp.wiki.plist:51: http://localhost:4444/app-context/wiki

1
  • I’ve added much detail to my answer - thanks for adding the extra detail to your post - that helped surface the correct plist you need to edit to change port 4444 to another port.
    – bmike
    May 4, 2018 at 3:56

2 Answers 2

3

Yes. Changing port is as simple as running it with a command line override:

selenium-server -port 4455

The above would try listening on port 4455 instead of 4444

Changing launchd is a little more work since you need to locate the exact file on the filesystem that it got the directions to listen on 4444.

Here is a nice write up of one such way to configure selenium to use port 4444

So, you’d need to edit the plist that controls the launch. I would recommend using homebrew to install this:

mac:dev me$ brew install selenium-server-standalone
==> Downloading https://selenium-release.storage.googleapis.com/3.11/selenium-server-standalone-3.11.0.jar
######################################################################## 100.0%
==> Caveats
To have launchd start selenium-server-standalone now and restart at login:
  brew services start selenium-server-standalone
Or, if you don't want/need a background service you can just run:
  selenium-server -port 4444
==> Summary
🍺  /usr/local/Cellar/selenium-server-standalone/3.11.0: 5 files, 22.3MB, built in 7 seconds
mac:dev me$ selenium-server -port 4455

You can see that you can override the port from this selenium server from the command line or edit ~/Library/LaunchAgents/homebrew.mxcl.selenium-server-standalone.plist to change these two lines that control the default port:

<string>-port</string>
<string>4444</string>

once you save the change, cycle the service using:

brew services restart selenium-server-standalone
0
6
+25

I suggesting noting which files you change and exactly how you change them, as updates to the Server app will very likely undo all of the changes you made. You may even want to make a shell script that looks for these files and automatically changes them at boot time, every time. I have to do something similar so my brew-installed apache doesn't get disrupted by the system's apache.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .