diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 8bf82c57..02ac08d8 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -5682,16 +5682,26 @@ add_option(struct options *options,
         re.remote = p[1];
         if (p[2])
         {
-            re.remote_port = p[2];
-            if (p[3])
+            /* Since port is optional, second parameter can be a protocol */
+            int proto = ascii2proto(p[2]);
+            sa_family_t af = ascii2af(p[2]);
+            if (proto < 0)
             {
-                const int proto = ascii2proto(p[3]);
-                const sa_family_t af = ascii2af(p[3]);
-                if (proto < 0)
+                /* Second is not proto, port then. Protocol should be third */
+                re.remote_port = p[2];
+                if (p[3])
                 {
-                    msg(msglevel, "remote: bad protocol associated with host %s: '%s'", p[1], p[3]);
-                    goto err;
+                    proto = ascii2proto(p[3]);
+                    af = ascii2af(p[3]);
+                    if (proto < 0)
+                    {
+                        msg(msglevel, "remote: bad protocol associated with host %s: '%s'", p[1], p[3]);
+                        goto err;
+                    }
                 }
+            }
+            if (proto >= 0)
+            {
                 re.proto = proto;
                 re.af = af;
             }
