11.15.4. Port Forwarding on Mac OS X

Currently, out of the box, Mac OS X only provides the following interfaces for loopback addresses:
  • localhost
  • 127.0.0.1
Therefore, port forwarding on Mac OS X may not work correctly. The following example shows error messages that can occur when attempting to configure port forwarding using the IP address of an application.

Example 11.23. Error Messages When Port Forwarding on Mac OS X

$ rhc port-forward myapp
Checking available ports...
Error trying to forward ports. You can try to forward manually by running:
ssh -N 70277280b8534c8a9fc76d2734393dfa@myapp-domain.example.com
The current workaround to enable port forwarding on Mac OS X is to manually configure an alias for each IP address used by the application:
$ sudo ifconfig lo0 alias application_IP_address

Example 11.24. Manually Configured IP Address

$ sudo ifconfig lo0 alias 127.10.51.129

Note

Root or administrative privileges are required to run the ifconfig command on Mac OS X.
If the application uses multiple IP addresses, you must configure an alias for each IP address. For example, suppose a PHP application has both MySQL and phpMyAdmin cartridges added, and it uses the IP addresses 127.11.25.1 and 127.11.25.2. For port forwarding to work correctly, configure an alias for each IP address as shown in the following example:

Example 11.25. Configuring Aliases for Multiple IP Addresses

$ sudo ifconfig lo0 alias 127.11.25.1
$ sudo ifconfig lo0 alias 127.11.25.2
Finally, enable port forwarding with the rhc port-forward command.

Important

The IP address alias configured for an application is not persistent through system reboots. If the system is rebooted, you must repeat these steps to correctly enable port forwarding on Mac OS X.