diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index bdd6450..39756b1 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -1828,7 +1828,7 @@ process_rsc_state(resource_t * rsc, node_t * node,
should_fence = TRUE;
} else if (is_set(data_set->flags, pe_flag_stonith_enabled)) {
- if (is_baremetal_remote_node(node) && is_not_set(node->details->remote_rsc->flags, pe_rsc_failed)) {
+ if (is_baremetal_remote_node(node) && node->details->remote_rsc && is_not_set(node->details->remote_rsc->flags, pe_rsc_failed)) {
/* setting unseen = true means that fencing of the remote node will
* only occur if the connection resource is not going to start somewhere.
* This allows connection resources on a failed cluster-node to move to
diff --git a/pengine/allocate.c b/pengine/allocate.c
index 3241273..7dd70f1 100644
--- a/pengine/allocate.c
+++ b/pengine/allocate.c
@@ -1636,6 +1636,7 @@ apply_remote_node_ordering(pe_working_set_t *data_set)
if (action->node == NULL ||
is_remote_node(action->node) == FALSE ||
+ action->node->details->remote_rsc == NULL ||
action->rsc == NULL ||
is_set(action->flags, pe_action_pseudo)) {
continue;
diff --git a/pengine/regression.sh b/pengine/regression.sh
index 9172acb..93d4de1 100755
--- a/pengine/regression.sh
+++ b/pengine/regression.sh
@@ -778,6 +778,7 @@ do_test remote-fence-unclean2 "Fence baremetal remote-node after cluster node f
do_test remote-move "Move remote-node connection resource"
do_test remote-disable "Disable a baremetal remote-node"
do_test remote-orphaned "Properly shutdown orphaned connection resource"
+do_test remote-orphaned2 "verify we can handle orphaned remote connections with active resources on the remote"
do_test remote-recover "Recover connection resource after cluster-node fails."
do_test remote-stale-node-entry "Make sure we properly handle leftover remote-node entries in the node section"
do_test remote-partial-migrate "Make sure partial migrations are handled before ops on the remote node."
diff --git a/pengine/test10/remote-orphaned2.dot b/pengine/test10/remote-orphaned2.dot
new file mode 100644
index 0000000..d8f1c9f
--- /dev/null
+++ b/pengine/test10/remote-orphaned2.dot
@@ -0,0 +1,2 @@
+ digraph "g" {
+}
diff --git a/pengine/test10/remote-orphaned2.exp b/pengine/test10/remote-orphaned2.exp
new file mode 100644
index 0000000..56e315f
--- /dev/null
+++ b/pengine/test10/remote-orphaned2.exp
@@ -0,0 +1 @@
+
diff --git a/pengine/test10/remote-orphaned2.scores b/pengine/test10/remote-orphaned2.scores
new file mode 100644
index 0000000..98853b1
--- /dev/null
+++ b/pengine/test10/remote-orphaned2.scores
@@ -0,0 +1 @@
+Allocation scores:
diff --git a/pengine/test10/remote-orphaned2.summary b/pengine/test10/remote-orphaned2.summary
new file mode 100644
index 0000000..f4e5e17
--- /dev/null
+++ b/pengine/test10/remote-orphaned2.summary
@@ -0,0 +1,27 @@
+
+Current cluster status:
+RemoteNode mrg-02: UNCLEAN (offline)
+RemoteNode mrg-03: UNCLEAN (offline)
+RemoteNode mrg-04: UNCLEAN (offline)
+Online: [ host-026 host-027 host-028 ]
+
+ neutron-openvswitch-agent-compute (ocf::heartbeat:Dummy): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ libvirtd-compute (systemd:libvirtd): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ ceilometer-compute (systemd:openstack-ceilometer-compute): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ nova-compute (systemd:openstack-nova-compute): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+
+Transition Summary:
+
+Executing cluster transition:
+
+Revised cluster status:
+RemoteNode mrg-02: UNCLEAN (offline)
+RemoteNode mrg-03: UNCLEAN (offline)
+RemoteNode mrg-04: UNCLEAN (offline)
+Online: [ host-026 host-027 host-028 ]
+
+ neutron-openvswitch-agent-compute (ocf::heartbeat:Dummy): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ libvirtd-compute (systemd:libvirtd): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ ceilometer-compute (systemd:openstack-ceilometer-compute): ORPHANED Started [ mrg-03 mrg-02 mrg-04 ]
+ nova-compute (systemd:openstack-nova-compute): ORPHANED Started [ mrg-03 mrg-02 mrg-04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